• Swift


    这个是一个第三方按钮菜单组件,原版是使用Objective-C编写的名为AwesomeMenu的组件,地址是:https://github.com/levey/AwesomeMenu

    这里改造成了Swift版,效果图如下:
     
      
      

    使用代码:
    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
    87
    88
    89
    import UIKit
     
    class ViewController: UIViewController,HanggeSwiftMenuDelegate {
         
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
             
            var storyMenuItemImage =  UIImage(named:"bg-menuitem.png")
            var storyMenuItemImagePressed =  UIImage(named:"bg-menuitem-highlighted.png")
            var starImage =  UIImage(named:"icon-star.png")
             
            // Default Menu
            var starMenuItem1 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem2 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem3 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem4 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem5 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem6 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem7 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem8 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
            var starMenuItem9 =  HanggeSwiftMenuItem(image:storyMenuItemImage!,
                highlightedImage:storyMenuItemImagePressed!, contentImage:starImage!,
                highlightedContentImage:nil)
             
            var menus =  [starMenuItem1, starMenuItem2, starMenuItem3, starMenuItem4,
                starMenuItem5, starMenuItem6, starMenuItem7,starMenuItem8,starMenuItem9]
             
            var 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")
            )
             
            var menu =  HanggeSwiftMenu(frame:self.view.bounds, startItem:startItem, aMenusArray:menus)
            menu.delegate = self
            self.view.addSubview(menu)
             
        }
        
        func SwiftSelectMenu(menu:HanggeSwiftMenu, didSelectIndex idx:Int)
        {
             
            println("Select the index : %d",idx)
        }
         
        func HanggeSwiftMenuDidFinishAnimationClose(menu:HanggeSwiftMenu)
        {
             
            println("Menu was closed!")
        }
         
        func HanggeSwiftMenuDidFinishAnimationOpen(menu:HanggeSwiftMenu)
        {
             
            println("Menu is open!")
        }
         
        func HanggeSwiftMenuWillAnimateOpen(menu:HanggeSwiftMenu)
        {
             
        }
         
        func HanggeSwiftMenuWillAnimateClose(menu:HanggeSwiftMenu)
        {
             
        }
         
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    }

    源码下载:HanggeMenu.zip

  • 相关阅读:
    判断qq浏览器和uc浏览器?
    做前端能避免的错误总结
    css布局
    border-radius后面写px/rem与百分比有什么区别?
    vertical-align
    localstorage和cookie的设置方法和获取方法
    怎么让列表的文字只显示两行,多出的出现省略号?
    avalon在公共页面里面写的功能,怎么让某些页面不引用到这个方法和html?
    小程序
    webpack
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/4838379.html
Copyright © 2020-2023  润新知