扩展示例菜单 0.4.0

扩展示例菜单 0.4.0

测试已测试
Lang语言 SwiftSwift
许可证 MIT
Released最后发布2018 年 10 月
SPM支持 SPM

monoqlo 维护。



扩展示例菜单

CI Status Version License Platform

demo

扩展示例菜单是用 Swift 编写的。

要求

  • iOS 8.0+
  • Xcode 10.0+
  • Swift 3.x+

安装

CocoaPods

您可以使用以下命令安装 CocoaPods:

$ gem install cocoapods

要使用 CocoaPods 将扩展示例菜单集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'ExpandingMenu', '~> 0.4'
end

然后,运行以下命令

$ pod install

Carthage

您可以使用以下命令通过 CarthageHomebrew 来安装

$ brew update
$ brew install carthage

要将 ExpandingMenu 集成到您使用 Carthage 的 Xcode 项目中,请在您的 Cartfile 中指定它

github "monoqlo/ExpandingMenu" ~> 0.4

运行 carthage update 以构建框架,并将生成的 ExpandingMenu.framework 拖动到您的 Xcode 项目中。

手动安装

  1. 下载并将 /ExpandingMenu 文件夹拖动到您的项目中。
  2. 恭喜您!

使用说明

import ExpandingMenu

let menuButtonSize: CGSize = CGSize(width: 64.0, height: 64.0)
let menuButton = ExpandingMenuButton(frame: CGRect(origin: CGPoint.zero, size: menuButtonSize), image: UIImage(named: "chooser-button-tab")!, rotatedImage: UIImage(named: "chooser-button-tab-highlighted")!)
menuButton.center = CGPoint(x: self.view.bounds.width - 32.0, y: self.view.bounds.height - 72.0)
view.addSubview(menuButton)

let item1 = ExpandingMenuItem(size: menuButtonSize, title: "Music", image: UIImage(named: "chooser-moment-icon-music")!, highlightedImage: UIImage(named: "chooser-moment-icon-music-highlighted")!, backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) { () -> Void in
            // Do some action
        }

・・・

let item5 = ExpandingMenuItem(size: menuButtonSize, title: "Sleep", image: UIImage(named: "chooser-moment-icon-sleep")!, highlightedImage: UIImage(named: "chooser-moment-icon-sleep-highlighted")!, backgroundImage: UIImage(named: "chooser-moment-button"), backgroundHighlightedImage: UIImage(named: "chooser-moment-button-highlighted")) { () -> Void in
            // Do some action
        }
        
menuButton.addMenuItems([item1, item2, item3, item4, item5])

自定义

ExpandingMenuButton

// Bottom dim view
menuButton.bottomViewColor = UIColor.redColor()
menuButton.bottomViewAlpha = 0.2

// Whether the tapped action fires when title are tapped
menuButton.titleTappedActionEnabled = false

// Menu item direction
menuButton.expandingDirection = .Bottom
menuButton.menuTitleDirection = .Right

// The action when the menu appears/disappears
menuButton.willPresentMenuItems = { (menu) -> Void in
    print("MenuItems will present.")
}

menuButton.didPresentMenuItems = { (menu) -> Void in
    print("MenuItems will present.")
}
        
menuButton.willDismissMenuItems = { (menu) -> Void in
    print("MenuItems dismissed.")
}

menuButton.didDismissMenuItems = { (menu) -> Void in
    print("MenuItems will present.")
}

// Expanding Animation
menuButton.enabledExpandingAnimations = [] // No animation

menuButton.enabledExpandingAnimations = CustomAnimationOptions.All.exclusiveOr(.MenuItemRotation)

// Folding Animation
menuButton.enabledFoldingAnimations = .All

menuButton.enabledFoldingAnimations = [.MenuItemMoving, .MenuItemFade, .MenuButtonRotation]

ExpandingMenuItem

// Title
item.title = "text"
item.titleColor = UIColor.redColor()

// Title margin to menu item
item.titleMargin = 4

作者

monoqlo, [email protected]

许可证

ExpandingMenu 可在 MIT 许可下使用。有关更多信息,请参阅 LICENSE 文件。