标签:
1 import UIKit 2 3 class ViewController: UIViewController,HanggeSwiftMenuDelegate { 4 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 // Do any additional setup after loading the view, typically from a nib. 8 9 var storyMenuItemImage = UIImage(named:"bg-menuitem.png") 10 var storyMenuItemImagePressed = UIImage(named:"bg-menuitem-highlighted.png") 11 var starImage = UIImage(named:"icon-star.png") 12 13 // Default Menu 14 var starMenuItem1 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 15 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 16 highlightedContentImage:nil) 17 var starMenuItem2 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 18 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 19 highlightedContentImage:nil) 20 var starMenuItem3 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 21 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 22 highlightedContentImage:nil) 23 var starMenuItem4 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 24 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 25 highlightedContentImage:nil) 26 var starMenuItem5 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 27 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 28 highlightedContentImage:nil) 29 var starMenuItem6 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 30 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 31 highlightedContentImage:nil) 32 var starMenuItem7 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 33 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 34 highlightedContentImage:nil) 35 var starMenuItem8 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 36 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 37 highlightedContentImage:nil) 38 var starMenuItem9 = HanggeSwiftMenuItem(image:storyMenuItemImage!, 39 highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, 40 highlightedContentImage:nil) 41 42 var menus = [starMenuItem1, starMenuItem2, starMenuItem3, starMenuItem4, 43 starMenuItem5, starMenuItem6, starMenuItem7,starMenuItem8,starMenuItem9] 44 45 var startItem = HanggeSwiftMenuItem(image:UIImage(named:"bg-addbutton.png")!, 46 highlightedImage:UIImage(named:"bg-addbutton-highlighted.png")!, 47 contentImage:UIImage(named:"icon-plus.png")!, 48 highlightedContentImage:UIImage(named:"icon-plus-highlighted.png") 49 ) 50 51 var menu = HanggeSwiftMenu(frame:self.view.bounds, startItem:startItem, aMenusArray:menus) 52 menu.delegate = self 53 self.view.addSubview(menu) 54 55 } 56 57 func SwiftSelectMenu(menu:HanggeSwiftMenu, didSelectIndex idx:Int) 58 { 59 60 println("Select the index : %d",idx) 61 } 62 63 func HanggeSwiftMenuDidFinishAnimationClose(menu:HanggeSwiftMenu) 64 { 65 66 println("Menu was closed!") 67 } 68 69 func HanggeSwiftMenuDidFinishAnimationOpen(menu:HanggeSwiftMenu) 70 { 71 72 println("Menu is open!") 73 } 74 75 func HanggeSwiftMenuWillAnimateOpen(menu:HanggeSwiftMenu) 76 { 77 78 } 79 80 func HanggeSwiftMenuWillAnimateClose(menu:HanggeSwiftMenu) 81 { 82 83 } 84 85 override func didReceiveMemoryWarning() { 86 super.didReceiveMemoryWarning() 87 // Dispose of any resources that can be recreated. 88 } 89 }
还有一个框架也是笔者非常喜欢的,在github上也是备受青睐:https://github.com/nicklockwood/iCarousel
不过目前swift版的还没有发布,如果你真想你的App更加生动,但是自己又不太想写,那么这个非常适合你
标签:
原文地址:http://www.cnblogs.com/iCocos/p/4671536.html