我在 iOS 8 中的 ImageView 上使用模糊效果,我想知道是否可以快速判断模糊效果应该有多强。
这是代码..
var blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
var visualEffectView = UIVisualEffectView(effect: blurEffect) as UIVisualEffectView
visualEffectView.frame = imageView.bounds
imageView.addSubview(visualEffectView)
最佳答案
目前无法这样做,您可以更改模糊 View 本身的 alpha 级别,但这会向您发出有关图形错误的警告,并且可能无法始终完美运行。
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIVisualEffectView/
Setting the Correct Alpha Value
When using the UIVisualEffectView class, avoid alpha values that are less than 1. Creating views that are partially transparent causes the system to combine the view and all the associated subviews during an offscreen render pass. UIVisualEffectView objects need to be combined as part of the content they are layered on top of in order to look correct. Setting the alpha to less than 1 on the visual effect view or any of its superviews causes many effects to look incorrect or not show up at all.
我知道的最好的解决方案是使用类似 FxBlurView 的东西您可以在其中更改您请求的效果的“blurRadius”。似乎没有什么比苹果实现更好的性能了,但只要您不打算在动画时操纵模糊 View 的边界,第 3 方库就足够了。
关于iphone - 在 iOS 8 中调整模糊效果的硬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28779963/