How to fade a UIVisualEffectView and/or UIBlurEffect in and out?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
If you want a blur view to appear and disappear smoothly in UIKit, there are two different effects you can animate. You can fade the entire UIVisualEffectView by changing its alpha, or you can animate the blur material itself by changing the effect property between nil and a UIBlurEffect.
Both techniques are valid, but they do not look the same. Fading alpha treats the blur like any other view. Animating effect makes the material itself transition, which usually feels more natural in iOS.
Fade the Whole View with alpha
If the blur is already configured and you just need a quick show or hide animation, animating alpha is the simplest approach:
This works well when the blur is acting like an overlay behind a sheet, menu, or modal. It is also useful when you want to animate other subviews on top of the blur at the same time.
Animate the effect Property for a Native Blur Transition
If you specifically want the blur intensity to ramp up and down, animate the effect property instead:
This is often the better answer when the question is really about UIBlurEffect, not just view visibility. The user sees the material appear, not merely a transparent layer becoming opaque.
Use UIViewPropertyAnimator for Interactive Blur
For drag gestures or interactive transitions, UIViewPropertyAnimator gives more control than a fixed UIView.animate block:
This pattern is useful when a pan gesture should control how strong the blur looks as the interface moves.
Choose the Right Technique for the Job
Use alpha when you want a simple fade of the whole view. Use effect when you want the blur itself to animate in a way that matches other UIKit materials. In some interfaces, the best result is a combination: animate the blur material with effect and separately fade labels or buttons layered above it.
You should also create the blur view once and reuse it. Rebuilding the view hierarchy every time you animate usually creates more layout work and makes the code harder to maintain.
Common Pitfalls
One common mistake is expecting an alpha animation to look identical to animating effect. The visual result is different, so choose deliberately rather than treating the two APIs as interchangeable.
Another problem is starting the animation before the blur view has the right frame or constraints. If the view is not laid out yet, the blur may animate in the wrong place.
Interactive animations also need care. If you use UIViewPropertyAnimator, keep the animator alive long enough and update fractionComplete on the same instance instead of recreating it every gesture event.
Finally, remember that heavy blur over a complicated interface can be expensive. If performance is poor, profile the view hierarchy before blaming the animation code alone.
Summary
- Animate
alphawhen you want a quick fade of the entire blur view. - Animate
effectwhen you want the blur material itself to transition in or out. - Use
UIViewPropertyAnimatorfor gesture-driven or interactive blur changes. - Lay out the blur view before animating it, and reuse the same view where possible.
- Pick the approach based on the visual result you actually want, not just on which API is shortest to type.
Related reading
- How to filter a RecyclerView with a SearchView
- How to filter specific apps for ACTION_SEND intent and set a different text for each app
- How to find actual number of lines of UILabel?
- How to find all available images for ImagesystemName
- How to find all available images for ImagesystemName
- How to find index of list item in Swift?
- How to find NSDocumentDirectory in Swift?
- How to find NSDocumentDirectory in Swift?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.