TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jan 2018 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Toshihiro Suzuki.
UIView based circle button with CAShapeLayer based progress stroke.
Colors and icon images are fully customizable. Either override or set preferred values.
Actually there's no default
appearance, so have fun.
open var defaultImage: UIImage?
open var inProgressImage: UIImage?
open var suspendedImage: UIImage?
open var completedImage: UIImage?
open var inProgressStrokeColor: UIColor?
open var suspendedStrokeColor: UIColor?
open var completedStrokeColor: UIColor?
open var touchedAlpha: CGFloat = 0.5
UIImage's contentMode
is .center
. Make sure you provide correct size of image.
state
: updates color and icon imageprogress
: updates stroke progressreset()
: mutates both state and progressIt is possible to update progress while suspended.
state
is read-only. Update via suspend()
, resume()
, complete()
and reset()
.
private var token: CircleProgressButton.DisposeToken?
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
token = button.onTap { state in
switch state {
case .inProgress:
print("suspend")
self.stopJob()
case .completed:
print("delete")
self.stopJob()
case .default:
print("start")
self.resumeJob()
case .suspended:
print("resume")
self.resumeJob()
}
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
token?.dispose()
}
override func viewDidLoad() {
super.viewDidLoad()
button.tapGesture.rx.event
.subscribe(...)
// ...
}
Feel free to assign your UIGestureRecognizerDelegate
.
button.tapGesture.delegate = self
MIT