Skip to content

Instantly share code, notes, and snippets.

@totocaster
Created April 28, 2016 10:07
Show Gist options
  • Save totocaster/27af07e4ddd4ea987f049665fec48e67 to your computer and use it in GitHub Desktop.
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/
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