如何将模糊应用于 UIView? [英] How to apply blur to a UIView?
问题描述
现在我正在构建一个需要模糊整个 UIView 的 iPhone 应用程序.我怎样才能做到这一点?我见过 这个框架,但我认为它不适用于 UIView.有没有其他方法可以模糊 UIView?
Right now I am building an iPhone app that requires blurring an entire UIView. How can I achieve this? I have seen this framework, but I don't think that works with UIView. Is there an alternate way to blur an UIView?
更新:在下面查看我更新的答案,增加了与 iOS 7 和 iOS 8 的相关性.
UPDATE: Check for my updated answer below, adding more relevance with the advent of iOS 7 and iOS 8.
推荐答案
自从 iOS 7 发布以来,这个问题一直受到很多点击,我想我应该跟进我最终做了什么.
Ever since the release of iOS 7, This question has been getting a lot of hits and I thought I should follow up on what I ended up doing.
当时我个人用 photoshop 模糊了图片,但是有很多很棒的第三方库可以做动态和静态em> 模糊,这里有几个:
I personally blurred the picture at the time with photoshop, but there are many great third party libraries available that do dynamic and static blurring, here are a couple:
- 这个巧妙的库从
UITabBar
中提取了一层,并应用于获得 iOS 7 原生模糊的任何视图:https://github.com/JagCesar/iOS-blur/ - 这个库是一个实时模糊库,可以实时模糊任何视图在它下面:https://github.com/alexdrone/ios-realtimeblur(正如所指出的by qegal)
- 另一个具有相同实时模糊效果的图像:https://github.com/nicklockwood/FXBlurView
- 这个图书馆是我个人使用的图书馆,它很棒,允许您可以在其他设置中设置色调颜色:https://github.com/ivoleko/ILTranslucentView
- This ingenious library takes a layer from
UITabBar
and applies to any view to get iOS 7's native blur: https://github.com/JagCesar/iOS-blur/ - This library is a real time blurring library that live blurs any view below it: https://github.com/alexdrone/ios-realtimeblur (as pointed out by qegal)
- Another one that does the same realtime blur: https://github.com/nicklockwood/FXBlurView
- This Library is the one I personally use and is Great, allowing you to set the tint color among other settings: https://github.com/ivoleko/ILTranslucentView
我想发布这个是因为您不再需要截取单个帧或屏幕的屏幕截图.
I wanted to post this because you no longer need to take screenshots of individual frames or screen.
iOS 8:随着即将发布的 iOS 8,Apple 包含了一个内置的模糊UIView
、UIVisualEffectView
(https://developer.apple.com/documentation/uikit/uivisualeffectview)
iOS 8: With the coming release of iOS 8, Apple has included a built in blurred UIView
, UIVisualEffectView
(https://developer.apple.com/documentation/uikit/uivisualeffectview)
这篇关于如何将模糊应用于 UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!