简体   繁体   中英

Swift - Custom UIImageView class

I was trying to find an answer to my question but couldn't find anything helpful.

I have an app that contains a lot of views, all views have at least one UIImageView. I need some of them to have UIBlurEffect on it, but I don't want to make an outlet for each and then create few lines of code for each to get desired blur.

My question is: How can I do this using custom UIImageView class (or another way)?

I have also tried doing this by creating extension for UIImageView and making @IBInspectable but unsuccessfully.

I would suggest creating a custom subclass of UIView that contains an image view, plus your UIVisualEffects (blur) view, and anything else you want.

You could expose an IBInspectable image property in this custom subclass and have the custom view install the image into it's child image view.

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