iOS 10 - 模糊背景不再起作用

标签 ios swift button uiblureffect

有人对 iOS10 上的 UIBlurEffect 有问题吗? 由于某种原因,我的按钮等的背景变得有点透明并且不再模糊......

    let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.ExtraLight)
    blurBackgroundView = UIVisualEffectView(effect: blurEffect)
    blurBackgroundView.frame = frame
    button = UIButton(frame: frame)   
    blurBackgroundView.layer.masksToBounds = true
    backgroundColor = UIColor.clearColor()
    addSubview(blurBackgroundView)
    addSubview(button)

这就是代码的样子......

如果我根据新文档将 UIBlurEffectStyle.ExtraLight 更改为 UIBlurEffectStyle.Prominent,按钮就会变得清晰......所以根本没有颜色!

最佳答案

将您想要模糊的内容添加到您的blurBackgroundView中。所以代替:

addSubview(blurBackgroundView)
addSubview(button)

你必须:

blurBackgroundView.addSubview(button)
addSubview(blurBackgroundView)

现在,当前 View 中 blurBackgroundView 下方的每个项目都将变得模糊,而您的按钮将保持原样。

关于iOS 10 - 模糊背景不再起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39999011/

相关文章:

swift - 每次我点击按钮它只会增加 50 个增量,

android - 按钮未显示在 LinearLayout 中

ios - 调用扩展函数 IOS Swift

ios - 我可以在我的主机应用程序中读取我的应用程序扩展的 info.plist 吗?

iphone - UILabel 中数字变化的动画

iphone - controllerview stopAnimating无法识别的选择器发送到实例

swift - 可选出现在结果中

swift - iOS 12 应用程序在 iPhone X/XS 的横向模式下与 UIImagePickerController 崩溃

ios - 应用内购买 appStoreReceiptURL 为空

android - 使用 Kotlin 将运行时边距设置为任何 View