标准iOS 7模糊实现 [英] Standard iOS 7 blur implementation
问题描述
我已经阅读了几十个关于在iOS早期版本中模仿iOS 7模糊效果的问题。但是这里出现的基本问题是iOS 7的 UIKit
真的有一个很好的和方便的方法来使任何 UIView
模糊?这对我来说似乎很合理。任何帮助感谢。
I have read dozens of questions about mimicking iOS 7 blur effect in earlier versions of iOS. But the fundamental question that arises here is does iOS 7's UIKit
really have a nice and convenient way to make any UIView
blurred? That seems quite logical to me. Any help appreciated.
推荐答案
UPDATE
从iOS 8.0 不是 iOS 7),UIKit提供 UIVisualEffectView
和 UIBlurEffect
。您可以观看 WWDC 2014会话419iOS应用的高级图形和动画 (或仅下载幻灯片)
UPDATE
As of iOS 8.0 (not iOS 7), UIKit provides UIVisualEffectView
and UIBlurEffect
. You can watch WWDC 2014 Session 419 "Advanced Graphics and Animations for iOS Apps" (or just download the slides) for an introduction to these classes.
不,它没有。苹果没有暴露一个接口这样做方便。例如,如果您通读此次讨论,Rincewind的回复应该明确表示,苹果不为此提供公共API,并且他们使用的私有API有严格的限制,可能会改变。
No, it doesn't. Apple has not exposed an interface for doing this conveniently. For example, if you read through this discussion, Rincewind's responses should make it clear that Apple doesn't provide a public API for this, and that the private APIs they use have serious limits and are likely to change.
您必须实现模糊效果自己。您可能想要使用新的 - [UIView drawViewHierarchyInRect:afterScreenUpdates:]
方法捕获背景视图的外观,然后应用 CIFilter
来执行模糊处理。
You must implement the blur effect yourself. You'll probably want to use the new -[UIView drawViewHierarchyInRect:afterScreenUpdates:]
method to capture the appearance of the background view, and then apply a CIFilter
to it to perform the blur.
这篇关于标准iOS 7模糊实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!