这个是一个第三方按钮菜单组件,原版是使用Objective-C编写的名为AwesomeMenu的组件,地址是:
https://github.com/levey/AwesomeMenu
源码下载:HanggeMenu.zip
这里改造成了Swift版,效果图如下:
(2015.10.20再次修改,在Swift2下使用正常。)
使用代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
import
UIKit
class
ViewController
:
UIViewController
,
HanggeSwiftMenuDelegate
{
override
func
viewDidLoad() {
super
.viewDidLoad()
let
storyMenuItemImage =
UIImage
(named:
"bg-menuitem.png"
)
storyMenuItemImagePressed =
"bg-menuitem-highlighted.png"
)
starImage =
"icon-star.png"
)
// Default Menu
starMenuItem1 =
HanggeSwiftMenuItem
(image:storyMenuItemImage!,
highlightedImage:storyMenuItemImagePressed!,contentImage:starImage!,
highlightedContentImage:
nil
)
starMenuItem2 =
)
starMenuItem3 =
)
starMenuItem4 =
)
starMenuItem5 =
)
starMenuItem6 =
)
starMenuItem7 =
)
starMenuItem8 =
)
starMenuItem9 =
)
menus = [starMenuItem1,starMenuItem2,starMenuItem3,starMenuItem4,
starMenuItem5,starMenuItem6,starMenuItem7,starMenuItem8,starMenuItem9]
startItem =
(image:
"bg-addbutton.png"
)!,
highlightedImage:
"bg-addbutton-highlighted.png"
403@contentImage:
"icon-plus.png"
highlightedContentImage:
"icon-plus-highlighted.png"
)
)
menu =
HanggeSwiftMenu
(frame:
self
.view.bounds,startItem:startItem,aMenusArray:menus)
menu.delegate =
self
.view.addSubview(menu)
}
func
SwiftSelectMenu
(menu:
Int
)
{
print
(
"Select the index : %d"
}
HanggeSwiftMenuDidFinishAnimationClose
)
{
"Menu was closed!"
)
}
HanggeSwiftMenuDidFinishAnimationOpen
)
{
"Menu is open!"
)
}
HanggeSwiftMenuWillAnimateOpen
)
{
}
HanggeSwiftMenuWillAnimateClose
)
{
}
didReceiveMemoryWarning() {
.didReceiveMemoryWarning()
}
}
|
原文出自: www.hangge.com 转载请保留原文链接: http://www.hangge.com/blog/cache/detail_649.html