Last active
July 26, 2017 14:50
-
-
Save e23z/f9b9c6383b6221e3c0dbea90b72b9b70 to your computer and use it in GitHub Desktop.
[Blurred Overlay] How to apply a blurred overlay to a view. #swift #ios #ui
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
//only apply the blur if the user hasn't disabled transparency effects | |
if !UIAccessibilityIsReduceTransparencyEnabled() { | |
self.view.backgroundColor = UIColor.clear | |
let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.dark) | |
let blurEffectView = UIVisualEffectView(effect: blurEffect) | |
//always fill the view | |
blurEffectView.frame = self.view.bounds | |
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight] | |
self.view.addSubview(blurEffectView) //if you have more UIViews, use an insertSubview API to place it where needed | |
} else { | |
self.view.backgroundColor = UIColor.black | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment