ZCSSlideToAction
is a UIView
subclass with a pan gesture recognizer. It replicates the interaction popularized by "Slide to Unlock" on the iOS lock screens. You can use it for any part of your applications where an action might warrant a confirmation dialog, but where such a dialog would be repeatitive.
Waiting for CocoaPods to support Swift projects.
You always instantiate a sub-class of ZCSSlideToAction
. ShimmerLabel
is the first one. I hope to release some more, and receive some submissions on Github.
Create a new UIView with a clear background (set background opacity to 0). Set its class to a sub-class of ZCSSlideToAction
, like ShimmerLabel
. Ensure that you set the containing View Controller as the ZCSSlideToAction
view's delegate
. Setup all the auto-layout constraints you want for the slider.
- Add
ZCSSlideToActionViewDelegate
to your View Controller. - Add
func slideToActionActivated() { ... }
to your View Controller.slideToActionActivated
will be called if the user slides the slider past the activation point (default: 66%).
There are a view properties you can tweak like so:
self.slideToActionView.activationPoint = 0.66
self.slideToActionView = true
Other delegate methods are available:
@objc protocol ZCSSlideToActionViewDelegate {
func slideToActionActivated()
optional func slideToActionStarted()
optional func slideToActionCancelled()
optional func slideToActionReset()
}
Requires Shimmer.
Has these configurable property defaults:
var willActivateColor:UIColor = UIColor.greenColor()
var willNotActivateColor:UIColor = UIColor.purpleColor()
var labelText:String = "> Slide to Action"
var labelTextColor:UIColor = UIColor.whiteColor()
var labelTextAlignment:NSTextAlignment = NSTextAlignment.Center
var labelFontName:String = "HelveticaNeue-Thin"
var labelFontSize:CGFloat = 55.0
Send me Pull Requests here, please. Especially interested in new slider styles.