iphone - 在 iOS 8 中调整模糊效果的硬度

标签 iphone swift ios8 blur

我在 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/

相关文章:

ios - iPhone map 方向

ios - 如何从 Xcode 中导入的 .dae 混合器访问混合形状

ios - iPhone 上的 UISplitViewController : pop to/show primary view from detail view controller

ios8 - 我们如何在 iOS 8 中指定应用程序方向?

ios - 在 UIImage 上添加一层颜色

iphone - 导航栏背景图片

iphone - 停止AVAudioPlayer

iphone - self.view.frame 在横向模式下意外更改了大小

ios - 如何快速创建 UnsafeMutablePointer<CGPoint> 对象

ios - 撤销按钮 Swift