Created
July 3, 2021 22:52
-
-
Save froggomad/11e402a7b8cf01e76f5be99e6623c1b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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