The Storyboard
has views Visual Effect View with Blur
and Visual Effect View with Blur and Vibrancy
. You can almost treat this like empty views.
So if you wanted a login dialog box that came up as a modal, but blur the background:
- The login dialog box would have its own View Controller
- Open the login dialog box as a modal
- Make sure the modal segue is
Over Current Context
so the screen below doesn't vanish - Add a
Visual Effect View with Blur
behind your other views, serving as a background - If you want, you can set the alpha on the Blur view to 0. Then animate the alpha on
viewDidAppear
override func viewDidAppear(animated: Bool) {
// add a semi-transparent background after the modal comes up
UIView.animateWithDuration(0.5,
delay: 0.0,
options: .CurveEaseIn,
animations: {
self.visualEffectView.alpha = 1.0
},
completion: nil
)
}
Sadly, if you do the animation above, you will get a warning:
<UIVisualEffectView 0x7ffd8e218790> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1.