如何将模糊应用于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模糊了这张照片,但是有很多很棒的第三方库可以用来做 动态 和 静态 模糊,以下是一对:
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 (由qegal指出) - 另一个执行相同实时模糊的工作:
https://github.com/ nicklockwood / FXBlurView - 此库是我个人使用的库, Great ,允许
你在其他设置中设置色调颜色:
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屋!