简体   繁体   中英

Quick way to replace UIVisualEffectView (or any view) in storyboard

I currently have a project targeted at iOS 8 on up; it is using the UIVisualEffectView offered in Xcode. I would like to target iOS 7, where this view is not supported. I would like to know if there is an easy way to switch out these views (in storyboard) with an equivalent open source "blur view" I've found. The UIVisualEffectView's have many subviews, so I would like a way to "switch" in the custom view while maintaining the subviews and constraints.

Since UIVisualEffectView was introduced in iOS 8 ( formerly private API in iOS 7 ) you can only use it on 8 and above. Therefore you cannot substitute with anything else in Storyboard.

One workaround would be to set the effect view to a your own subclass of UIView. There you can check whether or not UIVisualEffect is available and instantiate it on top of that view. If it's not, you can use an alternative blurring solution in order to replace it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM