Skip to content

Instantly share code, notes, and snippets.

@froggomad
Created July 3, 2021 22:52
Show Gist options
  • Select an option

  • Save froggomad/11e402a7b8cf01e76f5be99e6623c1b8 to your computer and use it in GitHub Desktop.

Select an option

Save froggomad/11e402a7b8cf01e76f5be99e6623c1b8 to your computer and use it in GitHub Desktop.
class AlertView: UIView {
@IBOutlet var closeButton: UIButton!
@IBAction func close(_ sender: UIButton) {
TapticEngine.pop()
flash(closeButton) { [weak self] _ in
self?.removeFromSuperview()
}
}
@IBOutlet var cancelButton: UIButton!
@IBAction func cancel(_ sender: UIButton) {
TapticEngine.cancelled()
flash(cancelButton)
}
@IBOutlet var popButton: UIButton!
@IBAction func pop(_ sender: UIButton) {
TapticEngine.pop()
flash(retryButton)
}
private func flash(_ view: UIView,
with duration: Double = 0.5,
color: UIColor = .yellow,
completion: @escaping (Bool) -> Void = { _ in }) {
UIView.animate(withDuration: duration, animations: {
view.backgroundColor = color
view.backgroundColor = .clear
},
completion: completion)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment