简体   繁体   English

UIVisualEffectView 在白色背景下“消失”

[英]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.我正在尝试重新创建一个类似于 App Store 故事页脚中使用的 UIVisualEffectView。 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.开箱,UIVisualEffectView与.light.extraLight.prominent ,或.default当被放置在白色背景上方blurEffect变得几乎不可见。 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.我想我在活力方面遗漏了一些明显的东西,但我已经调整了一段时间的值,但我无法正确地重新创建效果。

获取应用页脚


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)

截屏

You can always change the tone of your UIVisualEffectView by changing its background color.您始终可以通过更改其背景颜色来更改UIVisualEffectView的色调。 I guess you're looking for something like that我猜你正在寻找类似的东西

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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