PGMenu
一个用于您出色应用程序的菜单组件!
要求
- Swift 4.2。应与 Swift 3.* 兼容
示例项目
您可以在 PGMenu 文件夹中找到一个完全功能的演示
安装
手动安装
只需将 Source 文件夹拖放到您的项目中即可
Cocoapods
use_frameworks!
pod 'PGMenu'
使用PGMenu
- 创建一个ButtonConfiguration
数组,您可以使用此函数
func getButtonsParameters() -> [ButtonConfiguration<CircleButtonParameters, Any>] {
var parameters = [ButtonConfiguration<CircleButtonParameters, Any>]()
let airquality = getMenuItemConfiguration(imageName: "airquality",
gradient: Gradient(colors: (initColor: UIColor(rgb: 0x11998e), endColor: UIColor(rgb: 0x38ef7d)),
orientation: GradientOrientation.bottomRightTopLeft),
textMenuItem: "Air quality")
let journey = getMenuItemConfiguration(imageName: "journey",
gradient: Gradient(colors: (initColor: UIColor(rgb: 0x800080), endColor: UIColor(rgb: 0xffc0cb)),
orientation: GradientOrientation.bottomRightTopLeft), textMenuItem: "Journey")
parameters = [airquality, journey]
return parameters
}
- 创建StackMenu对象
let menuItems = self.getButtonsParameters()
let stackMenu = StackMenu(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height), configuration: menuItems)
- 设置委托
stackMenu.delegate = self
- 实现委托方法
extension ViewController: StackMenuDelegate {
@objc func stackMenu( pressedButtonAtIndex: Int) {
print("Pressed: \(#function) index: \(pressedButtonAtIndex)")
}
}
- 最后,将stackmenu添加到主视图
self.view.addSubview(stackMenu)
就这样....
支持/问题
如果您有任何问题,请毫不犹豫地创建一个问题。
许可证
PGMenu遵循MIT许可证。请参阅LICENSE文件以获取更多信息。
如果您使用它,我会很高兴知道。