gpt4 book ai didi

swift - UIBlurEffect 在我的 UIView 上没有按预期工作

转载 作者:行者123 更新时间:2023-11-28 07:06:29 26 4
gpt4 key购买 nike

我有一个 UIView,我在我的 viewDidLoad 中设置了它的框架。然后我使用 blurBackgroundForView 函数对其进行模糊处理:

override func viewDidLoad() {
super.viewDidLoad()
view.frame = CGRectMake(0, superView.frame.maxY-height, superView.frame.width, height)
// The view is supposed to peak in from the bottom
AnimationHelper.blurBackgroundForView(view)
}

static func blurBackgroundForView(view: UIView!){
view.backgroundColor = .clearColor()
let blurEffect = UIBlurEffect(style: .Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.frame
view.insertSubview(blurEffectView, atIndex: 0)
}
}

问题是 UIView 的背景没有模糊。当我将 blurBackgroundView(view) 的函数调用移至 view.frame = ... 上方时我得到一个模糊的 View ,但模糊的 View 太大了。

最佳答案

blurEffectView 的框架应该是 CGRectMake(0, 0, superview.frame.width, height)

关于swift - UIBlurEffect 在我的 UIView 上没有按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30383446/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com