简体   繁体   中英

Swift UIVisualEffectView with UIBlurEffect not working

I am trying to show UIView after clicking the floating action button. Once, I clicked the floating action button I need to rendering content view. Now if I try to apply blur effect , It is not working.

Here is my code:

fileprivate var parentView: UIView!

self.parentView = view
self.items = items
let bounds = self.parentView.bounds

self.contentView = UIView(frame: bounds)
self.blurVisualEffect = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight))
self.blurVisualEffect.frame = self.contentView.frame
self.contentView.addSubview(self.blurVisualEffect)

Sample Output

try this

let blurEffect = UIBlurEffect(style: .extraLight)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = self. parentView.bounds
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.contentView.addSubview(blurEffectView)

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