A customizable animated button inspired by the familiar button stack from Tinder
A customizable animated button built with Facebook's Pop animation library. Inspired by the familiar button stack from Tinder.
To run the example project, clone the repo and run the PopBounceButton-Example
target.
PopBounceButton is available through CocoaPods. To install it, simply add the following line to your Podfile
:
pod 'PopBounceButton'
PopBounceButton
directory into your project.Add a PopBounceButton
to your view.
let frame = CGRect(origin: .zero, size: CGSize(width: 100, height: 100))
let button = PopBounceButton(frame: frame)
view.addSubview(button)
Attach a target to your button to handle any events.
button.addTarget(self, action: #selector(handleTap), for: .touchUpInside)
@objc func handleTap(_ sender: PopBounceButton) {
//do something
}
Because PopBounceButton is a subclass of UIButton, it can be customized in the same way. The button's animations can be changed by modifying the following variables exposed by PopBounceButton
:
var springBounciness: CGFloat = 19.0
var springSpeed: CGFloat = 10.0
var springVelocity: CGFloat = 6.0
var cancelTapScaleDuration: TimeInterval = 0.3
var longPressScaleFactor: CGFloat = 0.7
var longPressScaleDuration: TimeInterval = 0.1
var minimumPressDuration: TimeInterval = 0.2
Mac Gallagher, [email protected]
PopBounceButton is available under the MIT License, see LICENSE for more infomation.