elfanek
elfanek

Reputation: 142

UIVisualEffectView 'disappears' when placed against a white background

I'm trying to recreate a UIVisualEffectView similar to the one used in the footer of App Store stories. While it looks pretty straight forward, I'm having trouble configuring the blur to respond the same way when against a white background.

Out of the box, UIVisualEffectView with a .light, .extraLight, .prominent, or .default blurEffect becomes pretty much invisible when placed above a white background. I think I'm missing something obvious with the vibrancy, but I've been tweaking values for a while now and I haven't been able to recreate the effect properly.

Get app footer


Here's what I'm doing, and what it looks like when against a completely white background.

let backgroundView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 300))
backgroundView.backgroundColor = .white
view.addSubview(backgroundView)

let blurView = UIVisualEffectView(effect: UIBlurEffect(style: .extraLight))
blurView.frame = CGRect(x: 50, y: 50, width: 150, height: 150)
backgroundView.addSubview(blurView)

screenshot

Upvotes: 1

Views: 653

Answers (1)

Yury Imashev
Yury Imashev

Reputation: 2128

You can always change the tone of your UIVisualEffectView by changing its background color. I guess you're looking for something like that

blurView.backgroundColor = UIColor.lightGray.withAlphaComponent(0.7)

Upvotes: 1

Related Questions