Skip to content

bennagar/BNSwipeableButton

Repository files navigation

BNSwipeableButton

build Swift 3.0 platform platform platform

BNSwipeableButton is a Swift button that can be swiped to change its state. Created by Ben Nagar.

Animation

Requirements

  • Xcode 8.2+
  • iOS 8.0+

Installation

Just add BNSwipeableButton.swift to your project.

Usage

  1. Create BNSwipeableButton instance, with storyboard or just with code

  2. On your view controller viewDidLoad call the setup() 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)
  }
  1. Confirm to BNSwipeableButtonDelegate for handling button events
  protocol BNSwipeableButtonDelegate: class {
      func buttonDidTap()
      func buttonPageDidChange(to page:Int)
  }

License

BNSwipeableButton is available under the MIT license. See the LICENSE file for more info.

Follow on Twitter ✨CodeLetter ✎ ✨ platform

About

Swift button that can be swiped to change its state

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages