BNSwipeableButton is a Swift button that can be swiped to change its state. Created by Ben Nagar.
- Xcode 8.2+
- iOS 8.0+
Just add BNSwipeableButton.swift to your project.
-
Create
BNSwipeableButton
instance, with storyboard or just with code -
On your view controller
viewDidLoad
call thesetup()
function with a list of colors for the different button pages
@IBOutlet var button: BNSwipeableButton!
override func viewDidLoad() {
super.viewDidLoad()
button.setup(colors: [(.blue,.green), (.green,.yellow), (.yellow,.red), (.red,.purple)], delegate: self)
}
- Confirm to
BNSwipeableButtonDelegate
for handling button events
protocol BNSwipeableButtonDelegate: class {
func buttonDidTap()
func buttonPageDidChange(to page:Int)
}
BNSwipeableButton is available under the MIT license. See the LICENSE file for more info.
Follow on Twitter ✨CodeLetter ✎ ✨