Skip to content

Instantly share code, notes, and snippets.

@bitops
Last active August 11, 2020 21:24
Show Gist options
  • Save bitops/cb11ff24cb72bd37a6b04e432e1161fe to your computer and use it in GitHub Desktop.
Save bitops/cb11ff24cb72bd37a6b04e432e1161fe to your computer and use it in GitHub Desktop.
UIViewController that frosts a portion of the screen. The `toggleBlur` method is hooked up to a button on the story board.
class BlurViewController: UIViewController {
var blurView : UIVisualEffectView!
override func viewDidLoad() {
let frame = CGRect(x: view.bounds.maxX * 0.1, y: view.bounds.maxY * 0.4, width: 350, height: 200)
blurView = UIVisualEffectView(frame: frame)
blurView.effect = UIBlurEffect(style: .systemUltraThinMaterial)
view.addSubview(blurView)
}
@IBAction func toggleBlur() {
blurView.isHidden = !blurView.isHidden
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment