如何将模糊应用于UIView? [英] How to apply blur to a UIView?

查看:163
本文介绍了如何将模糊应用于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:

  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆