An Menu component for your awesome apps!
- Swift 4.2. Should work with Swift 3.*
You have a fully functional demo in PGMenu folder
Just drag and drop Source folder in your project
use_frameworks!
pod 'PGMenu'
- Create an array of ButtonConfiguration<CircleButtonParameters, Any> you can use this function:
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
}
- Create the StackMenu object
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)
- Set the delegate
stackMenu.delegate = self
- Implement the delegate method
extension ViewController: StackMenuDelegate {
@objc func stackMenu( pressedButtonAtIndex: Int) {
print("Pressed: \(#function) index: \(pressedButtonAtIndex)")
}
}
- And finally, add the stackmenu to the main view
self.view.addSubview(stackMenu)
And voilá....
If you have any questions, please don't hesitate to create an issue.
PGMenu is available under the MIT license. See the LICENSE file for more info.
If you use it, I'll be happy to know about it.