Clean and beautiful menu option button written in Swift.
Simply copy the LDOptionButton.swift
file into your project.
Or if you use Cocoapods then add the following to your Podfile:
pod 'LDOptionButton'
Or if you use Carthage add the following to your Cartfile:
github "lajosdeme/LDOptionButton'
//Create the configurations for the side buttons
let configs = [
SideButtonConfig(backgroundColor: .blue, normalIcon: "settings"),
SideButtonConfig(backgroundColor: .green, normalIcon: "info"),
SideButtonConfig(backgroundColor: .red, normalIcon: "location")
]
//Create the button, set its properties and pass in configs
button = LDOptionButton(frame: CGRect(x: view.bounds.width - 100 , y: view.bounds.height - 130, width: 50, height: 50),
normalIcon: "home",
selectedIcon: "close",
buttonsCount: 3,
sideButtonConfigs: configs,
duration: 0.2)
button.startAngle = 0
button.endAngle = 90
button.delegate = self
//Delegate methods
//Side button at the specified index will be selected
func optionButton(optionButton: LDOptionButton, willSelect button: UIButton, atIndex: Int)
//Side button at the specified index was selected
func optionButton(optionButton: LDOptionButton, didSelect button: UIButton, atIndex: Int)
//Option button was selected and the side buttons are displayed
func optionButton(didOpen options: LDOptionButton)
//Option button was closed and the side buttons are not displayed anymore
func optionButton(didClose options: LDOptionButton)
- Drag a
UIButton
onto the scene - Set its properties via the Attributes Inspector
- Connect it to code
- Add delegate methods, start using it
If you have any suggestions or questions feel free to raise an issue or reach out to me directly via lajosd@protonmail.ch.
If you like this button you can thank me by buying me a coffee.