A UIView subclass that supports UIVisualEffect without all the boiler plate code needed to create one and nest the view hierarchy. It's really easy to use, you can use it in xib document, create one programmatically or install on an already placed view.
- iOS8 or above
- Autolayout
You can create AFBlurView
directly in a xib document, by placing a UIView
and changing the custom class in the identity inspector. Even if the best way is later add another subview with inside all the contents that you want to display AFBlurView
will move all its single subviews into the blur/vibracy hidden content view by keeping the original constraints.
Using the attribute inspector is also possible to set the vibrancy effect (enabled/disabled) and the blur style.
Unfortunately the blur style is represented using integers:
- 0 = ExtraLightBlur
- 1 = LightBlur
- 2 = DarkBlur
Using the class method:
+ (instancetype) installAndMakeSubview:(UIView*) view;
is possible to make and already existing view with all its subviews be a subview of the blur/vibracy hidden content view by keeping the original constraints.
Using that method is possible to create an AFBlurView
- (instancetype) initWithFrame:(CGRect)frame
withEffectStyle:(AFBlurEffect) style
andVibrancy:(BOOL) vibrancyEnabled;
To enable or disable the vibrancy effect use the property:
@property (assign, nonatomic, getter=isVibrancyEnabled) IBInspectable BOOL vibrancyEnabled;
To change the blur effect, use the property:
@property (assign, nonatomic) AFBlurEffect blurEffect;
AFBlurEffect
is a remap of the UIVisualEffect
enumeration and has these effects:
- AFBlurEffectExtraLight
- AFBlurEffectLight
- AFBlurEffectDark
Just copy the two files AFBlurView
.h
.m
in your project.
AFBlurView
is released under MIT license. See LICENSE for details.