MenuButton
MenuButton 允许您轻松展示您令人惊叹的新应用功能。
它是从头开始设计的,可以根据您的需求完全自定义。
示例
示例应用程序是查看 MenuButton
在实际应用中的表现的好方法。您将简要了解可用的配置选项以及它们如何影响 ViewController
的外观和感觉。只需打开 MenuButton.xcodeproj
并运行 Example
构建方案即可。
安装
CocoaPods
MenuButton 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中。
pod 'MenuButton', '~> 1.0.0'
手动
如果您不希望使用上述任何依赖管理工具,您可以手动将 MenuButton 集成到您的项目中。只需将 源
文件夹拖入您的 Xcode 项目。
用法
以下第一个用法描述展示了使用 MenuButton
展示您的新应用程序功能的简单方法。
MenuButton
要展示您的新应用程序中的出色功能,只需通过 InterfaceBuilder 或手动配置 MenuButton 类。
// Initialize MenuButton
let menuButtonView = MenuButtonView(frame: CGRect(x: 295.0, y: 587.0, width: 60.0, height: 60.0)
menuButtonView.bindView(self.view)
menuButtonView.onDeselect = { print("view was deselect") }
menuButtonView.onItems = makeItems()
menuButtonView.onConfigure = makeConfiguration()
MenuItem
配置 MenuButton 的类
// Initialize MenuItems
func makeItems() -> (() -> [MenuItem]) {
return {
return [
MenuItem(image: UIImage(named: "1")!, text: "Go to Mission Chat", action: { print("Clicked at: Go to Mission Chat") }),
MenuItem(image: UIImage(named: "2")!, text: "Open Flight Plan", action: { print("Clicked at: Open Flight Plan") }),
MenuItem(image: UIImage(named: "3")!, text: "Complete Mission", action: { print("Clicked at: Complete Mission") }),
MenuItem(image: UIImage(named: "4")!, text: "Add Media", action: { print("Clicked at: Add Media") }),
MenuItem(image: UIImage(named: "5")!, text: "Show on Map", action: { print("Clicked at: Show on Map") }),
MenuItem(image: UIImage(named: "6")!, text: "Send Email to Mission Creator", action: { print("Clicked at: Send Email to Mission Creator") }),
MenuItem(image: UIImage(named: "7")!, text: "Phone Mission Creator", action: { print("Clicked at: Phone Mission Creator") }),
MenuItem(image: UIImage(named: "8")!, text: "Hide Mission from Mission List", action: { print("Clicked at: Hide Mission from Mission List") })
]
}
}
MenuButtonViewConfig
配置 MenuButton 的枚举
enum MenuButtonViewConfig {
case textMenuColor(UIColor)
case textMenuFont(UIFont)
case textMenuSize(CGFloat)
case menuCellHeight(CGFloat)
case menuWidth(CGFloat)
case strokeColor(UIColor)
case borderStrokeColor(UIColor)
case borderLineWidth(CGFloat)
case lineWidth(CGFloat)
case offset(CGFloat)
case distanceBetweenLines(CGFloat)
case animationDuration(CFTimeInterval)
case menuType(MenuType)
case showType(MenuShowType)
}
func makeConfiguration() -> (() -> [MenuButtonViewConfig]) {
return {
return [
.strokeColor(.red),
.borderStrokeColor(.red),
.textMenuColor(.blue),
.menuCellHeight(50.0),
.menuWidth(600.0),
]
}
}
下一小节将解释 MenuButton 的所有属性。
配置
当用户点击背景视图时的调用。
var onDeselect: (() -> Void)?
当菜单准备显示时的调用。相当于委托方法。
var onItems: (() -> [MenuItem])?
当菜单需要获取配置自身。
var onConfigure: (() -> [MenuButtonViewConfig])?
欢迎贡献
非常欢迎贡献
许可协议
MenuButton
Copyright (c) 2018 Andrii Starostenko <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.