gpt4 book ai didi

ios - 如何减少 UIVisualEffectView 上的模糊效果

转载 作者:行者123 更新时间:2023-11-30 11:41:36 26 4
gpt4 key购买 nike

如何减少 UIVisualEffectView 上的模糊效果,它为我提供了光、额外光和暗的选项,这对我来说还不够好,我正在尝试实现这样的目标 enter image description here

最佳答案

我们完全可以使用动画师以本地方式做到这一点,并具有正确的预期外观

用法:

let blurEffectView = BlurEffectView()
view.addSubview(blurEffectView)

BlurEffectView实现:

class BlurEffectView: UIVisualEffectView {

var animator = UIViewPropertyAnimator(duration: 1, curve: .linear)

override func didMoveToSuperview() {
guard let superview = superview else { return }
backgroundColor = .clear
frame = superview.bounds //Or setup constraints instead
setupBlur()
}

private func setupBlur() {
animator.stopAnimation(true)
effect = nil

animator.addAnimations { [weak self] in
self?.effect = UIBlurEffect(style: .dark)
}
animator.fractionComplete = 0.1 //This is your blur intensity in range 0 - 1
}

deinit {
animator.stopAnimation(true)
}
}

关于ios - 如何减少 UIVisualEffectView 上的模糊效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49238595/

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