我如何产生类似于iOS 7模糊视图的效果? [英] How can I produce an effect similar to the iOS 7 blur view?

查看:86
本文介绍了我如何产生类似于iOS 7模糊视图的效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从苹果公开发布的iOS 7示例屏幕复制这个模糊的背景:



这个问题建议对以下内容应用CI过滤器,但这是一种完全不同的方法。很明显,iOS 7并没有捕获下面视图的内容,原因很多:


  1. 做一些粗略的测试,截取截图的视图,并且应用具有足够大半径的CIGaussianBlur过滤器来模拟iOS 7的模糊风格需要1-2秒,即使在模拟器上也是如此。

  2. iOS 7模糊视图能够对动态视图(如视频或动画)进行模糊处理,而且没有明显的延迟。

任何人都可以推测他们可以使用什么框架创建这种效果,如果可以用当前的公共API创建类似的效果?



编辑:(来自评论)我们不完全知道苹果是如何做的,但是我们可以做出什么基本的假设?我们可以假设他们正在使用硬件,对吧?

效果是否独立于每个视图中,使得效果实际上不知道它背后的内容?还是必须根据模糊的工作原理来考虑模糊背后的内容?如果效果背后的内容是相关的,我们可以假设Apple正在接收下面内容的feed,并且不断渲染它们以模糊?

解决方案

为什么要复制效果?只需在视图后面绘制UIToolbar即可。

  myView.backgroundColor = [UIColor clearColor]; 
UIToolbar * bgToolbar = [[UIToolbar alloc] initWithFrame:myView.frame];
bgToolbar.barStyle = UIBarStyleDefault;
[myView.superview insertSubview:bgToolbar belowSubview:myView];


I'm trying to replicate this blurred background from Apple's publicly released iOS 7 example screen:

This question suggests applying a CI filter to the contents below, but that's a whole different approach. It's obvious that iOS 7 doesn't capture the contents of the views below, for many reasons:

  1. Doing some rough testing, capturing a screenshot of the views below and applying a CIGaussianBlur filter with a large enough radius to mimic iOS 7's blur style takes 1-2 seconds, even on a simulator.
  2. The iOS 7 blur view is able to blur over dynamic views, such as a video or animations, with no noticeable lag.

Can anyone hypothesize what frameworks they could be using to create this effect, and if it's possible to create a similar effect with current public APIs?

Edit: (from comment) We don't exactly know how Apple is doing it, but are there any basic assumptions we can make? We can assume they are using hardware, right?

Is the effect self-contained in each view, such that the effect doesn't actually know what's behind it? Or must, based on how blurs work, the contents behind the blur be taken into consideration?

If the contents behind the effect are relevant, can we assume that Apple is receiving a "feed" of the contents below and continuously rendering them with a blur?

解决方案

Why bother replicating the effect? Just draw a UIToolbar behind your view.

myView.backgroundColor = [UIColor clearColor];
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:myView.frame];
bgToolbar.barStyle = UIBarStyleDefault;
[myView.superview insertSubview:bgToolbar belowSubview:myView];

这篇关于我如何产生类似于iOS 7模糊视图的效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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