Gongra Mon
Gongra Mon

Reputation: 67

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

Upvotes: 2

Views: 1138

Answers (1)

pigeon_39
pigeon_39

Reputation: 1513

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)

Upvotes: 1

Related Questions