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

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

问题描述

我正在尝试从 Apple 公开发布的 iOS 7 示例屏幕中复制这种模糊的背景:

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

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

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. 做一些粗略的测试,捕捉下面视图的屏幕截图并应用具有足够大半径的 CIGaussianBlur 过滤器来模仿 iOS 7 的模糊样式,即使在模拟器上也需要 1-2 秒.
  2. iOS 7 模糊视图能够在动态视图(例如视频或动画)上进行模糊处理,没有明显的延迟.

谁能假设他们可以使用哪些框架来创建这种效果,以及是否可以使用当前的公共 API 来创建类似的效果?

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?

(来自评论)我们并不完全知道 Apple 是怎么做的,但是我们可以做出任何基本假设吗?我们可以假设他们正在使用硬件,对吗?

(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?

如果效果背后的内容是相关的,我们是否可以假设 Apple 正在接收下面内容的提要"并持续模糊地渲染它们?

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?

推荐答案

为什么要复制效果?只需在您的视图后面绘制一个 UIToolbar.

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天全站免登陆