Skip to content

Clean and beautiful menu option button written in Swift.

License

Notifications You must be signed in to change notification settings

lajosdeme/LDOptionButton

Repository files navigation

LDOptionButton

Clean and beautiful menu option button written in Swift.

scrn2 scrn1-min

Installation

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'

Usage

Programatically

//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)

Storyboard

  1. Drag a UIButton onto the scene
  2. Set its properties via the Attributes Inspector
  3. Connect it to code
  4. Add delegate methods, start using it

Contributing

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.

Buy Me A Coffee

About

Clean and beautiful menu option button written in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published