Swift - 炫酷放射弹出按钮菜单(改造自AwesomeMenu)
(本文代码已升级至Swift3)
这里改造成了Swift版,效果图如下:
使用代码:
import UIKit class ViewController: UIViewController,HanggeSwiftMenuDelegate { override func viewDidLoad() { super.viewDidLoad() let storyMenuItemImage = UIImage(named:"bg-menuitem.png") let storyMenuItemImagePressed = UIImage(named:"bg-menuitem-highlighted.png") let starImage = UIImage(named:"icon-star.png") // Default Menu let starMenuItem1 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem2 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem3 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem4 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem5 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem6 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem7 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem8 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let starMenuItem9 = HanggeSwiftMenuItem(image:storyMenuItemImage!, highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!, highlightedContentImage:nil) let menus = [starMenuItem1, starMenuItem2, starMenuItem3, starMenuItem4, starMenuItem5, starMenuItem6, starMenuItem7,starMenuItem8,starMenuItem9] let startItem = HanggeSwiftMenuItem(image:UIImage(named:"bg-addbutton.png")!, highlightedImage:UIImage(named:"bg-addbutton-highlighted.png")!, contentImage:UIImage(named:"icon-plus.png")!, highlightedContentImage:UIImage(named:"icon-plus-highlighted.png") ) let menu = HanggeSwiftMenu(frame:self.view.bounds, startItem:startItem, aMenusArray:menus) menu.delegate = self self.view.addSubview(menu) } func SwiftSelectMenu(_ menu:HanggeSwiftMenu, didSelectIndex idx:Int) { print("Select the index : %d",idx) } func HanggeSwiftMenuDidFinishAnimationClose(_ menu:HanggeSwiftMenu) { print("Menu was closed!") } func HanggeSwiftMenuDidFinishAnimationOpen(_ menu:HanggeSwiftMenu) { print("Menu is open!") } func HanggeSwiftMenuWillAnimateOpen(_ menu:HanggeSwiftMenu) { } func HanggeSwiftMenuWillAnimateClose(_ menu:HanggeSwiftMenu) { } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } }
swift3全是报错
源码报错太多实在改不动了
http://www.ios122.com/2015/08/awesomemenu/ 这是我整理的awesomemenu 上的github上的最新版,LZ这个是官方出的swift版吗?我在github上,没有看到相关的 issue 或者 pull request.