iPhone SDK - 磨砂玻璃(iOS 7模糊)效果 [英] iPhone SDK - Frosted Glass (iOS 7 Blur) Effect

查看:180
本文介绍了iPhone SDK - 磨砂玻璃(iOS 7模糊)效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在UIImageView中应用磨砂玻璃效果



我试图实现我发现的



UPDATE 1 strong>



所以经过一点研究,我最终发现iOS的Core Image还是不完整的,当比较OS X版本的库。所以我google了很多,我找到两个解决方案,其中一个更简单,另一个更广泛和复杂的库。





所以,例如,在几行我可以得到我想要的结果(其中originalImage是UIImage应用效果):

  GPUImageGaussianBlurFilter * blurFilter = [[GPUImageGaussianBlurFilter alloc] init]; 
blurFilter.blurSize = 2;
UIImage * blurImage = [blurFilter imageByFilteringImage:resizedImage];

UPDATE 2



苹果宣布iOS 7之后,一些开发人员发现了一个解决方法来做与苹果在默认iOS应用程序中一样的做法,因为苹果没有提供API。 在我看来,最简单和更好的解决方案是这一个。为什么我认为这是最好的?因为即使它背后的一些视图移动,模糊仍然适用于更新的效果,因为我们预期它应该工作。但是,请记住,这取决于iOS 7 SDK为了工作,它如果Apple更改UIToolbar,可能会有风险。



UPDATE 3



<在WWDC 2013(会话226 - 在iOS上实现互动UI)中,他们将在UIImage上提供一个类别类,名为 UIImage + ImageEffects (我已将其标记为并在此处找到,但它可在开发人员门户 - 在搜索框中搜索UIImageEffects )。使用此类别,您可以使用几种方法(亮,暗,具有特定颜色等)在静态UIImage中应用模糊。此外,昨天我看到这个组件,发现它很有趣,因为你可以应用效果(基于



更新4 ,在iOS 8上,苹果发布了新的类,可以轻松地做现场模糊。使用 UIVisualEffect UIVisualEffectView ,您可以快速添加实时模糊到您的应用程序。 这是一个很好的教程,从Ryan Nystrom如何使用这些类(和模糊一般)


I am trying to apply a frosted glass effect in a UIImageView.

I tried to implement what i've found in this question, but the result wasn't acceptable. I wanted something like this:

Any ideas?

UPDATE:

Also, we can see that iOS 7 uses this kind of effect in a lot of places. How can we reproduce it?

解决方案

A good tutorial about CoreImage is here, showing how to apply filters and more:

http://www.raywenderlich.com/5689/beginning-core-image-in-ios-5

UPDATE 1

So after a little bit of research, I ended up discovering that the Core Image for the iOS is still incomplete, when comparing to the OS X version of the library. So I googled a lot, and I find two solutions, one of them more simple, and the other much wider and complex library.

So, for example, in a few lines I can get the result I want (where originalImage is the UIImage to apply the effect):

GPUImageGaussianBlurFilter *blurFilter = [[GPUImageGaussianBlurFilter alloc] init];
blurFilter.blurSize = 2;
UIImage *blurImage = [blurFilter imageByFilteringImage:resizedImage];

UPDATE 2

After Apple announced iOS 7, some developers found a workaround to do the same that Apple did in the default iOS apps, as Apple didn't provide an API for that. The simplest and better solution, in my opinion, is this one. Why I think it's the best? Because even if some view behind it moves, the blur still works great with the updated effect, as we expect it should work. However, bear in mind that it depends on the iOS 7 SDK in order to work, and it can be risky if Apple changes UIToolbar.

UPDATE 3

Apple mentioned, at WWDC 2013 (Session 226 - Implementing Engaging UI on iOS) they would provide a category class on UIImage, called UIImage+ImageEffects (I googled it, and found here, but it's available in Developer Portal - search for UIImageEffects in the search box). With this category, you can apply the blur in a static UIImage, using several methods (light, dark, with a specific color, etc.). Also, yesterday I saw this component and found it pretty interesting, as you can apply the effect (based on the above mentioned category) in a frame.

UPDATE 4

Finally, on iOS 8, Apple released new classes that can do live blur easily. With UIVisualEffect and UIVisualEffectView, you can quickly add live blur to your apps. Here is a good tutorial from Ryan Nystrom on how to use those classes (and in blur in general):

这篇关于iPhone SDK - 磨砂玻璃(iOS 7模糊)效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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