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

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

  • 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 包含了一个内置的模糊UIViewUIVisualEffectView(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天全站免登陆