Created
April 28, 2016 10:07
-
-
Save totocaster/27af07e4ddd4ea987f049665fec48e67 to your computer and use it in GitHub Desktop.
Flashes screen with white rectangle. Taken from: https://realm.io/news/tryswift-adam-bell-prototyping-magic/
This file contains 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
import UIKit | |
public extension UIWindow { | |
public func flash() { | |
let flashView = UIView(frame: bounds) | |
flashView.userInteractionEnabled = false | |
flashView.backgroundColor = UIColor.whiteColor() | |
addSubview(flashView) | |
UIView.animateWithDuration(0.75, delay: 0.0, options: .CurveEaseOut, animations: { | |
flashView.alpha = CGFloat(0.0) | |
}, completion: { (finished) in | |
flashView.removeFromSuperview() | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment