iOS 8活力图像未在设备上显示 [英] iOS 8 vibrancy image not showing on device

查看:125
本文介绍了iOS 8活力图像未在设备上显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用Xcode for iOS 8创建了一个简单的应用程序,并在界面构建器中使用了新的Visual Effects View with Blur and Vibrancy对象。它适用于文本,但所有图像似乎仅在模拟器中工作,而在任何硬件上都没有。

So I created a simple app using Xcode for iOS 8, and used the new "Visual Effects View with Blur and Vibrancy" object in the interface builder. It works great for text but all the images seem to only work in the simulators, and none on any hardware.

为了说明我的确切内容意思是,这是一个比较。
模拟器中的屏幕截图(预期外观):

To illustrate exactly what I mean, here's a comparison. Screenshot in simulator (intended look):

iPhone上的屏幕截图(8.3,与模拟器版本相同):

Screenshot on iPhone (8.3, same as simulator version):

所以三个圆形元素是:一个图像,一个与背景图像相同的按钮,以及相同的按钮,但没有活力效果(norm。 BTN)。似乎模糊+活力效果是通过两个视觉效果视图在Xcode中完成的 - 一个实现模糊的顶视图,以及在属性窗口中也检查了活力的嵌套视图。

So the three round elements are: an image, a button with the same image as background, and the same button but without the vibrancy effect ("norm. btn"). It seems like the blur + vibrancy effect is done in Xcode by having two "Visual Effect views" - a top view that implements just blur, and a nested view that also has "vibrancy" checked in the attributes window.

知道为什么会这样吗?我非常喜欢图像中活力的外观,但它不适用于我的iPhone 5s或我的iPad Air 2.

Any idea why this is happening? I really like the looks of the vibrancy in images, but it's not working on my iPhone 5s or my iPad Air 2.

非常感谢!!!

更新:
我做了一些研究,发现我收到警告正在被要求动画显示其不透明度。这将导致效果在不透明度返回到1之前出现断裂。最初我认为这打破了活力效果,但是在删除所有动画并且不再发出警告后,图像仍然是不可见的。我发现警告只是意味着当VisualEffectView的alpha还不是1时,活力不会开始工作(看起来是灰色的)。

Update: I did some research, and found that I was getting the warning " is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1." Initially I thought that was breaking the vibrancy effect, but upon removing all animations and not getting the warning any more, the images are still invisible. I found out that the warning simply means when the alpha of the VisualEffectView is not yet 1, the vibrancy doesn't begin working (looks grey-ish).

我也是发现图像确实显示(以破碎的方式显示,即看起来黑色而不是充满活力的过渡),但当alpha达到1时它们会消失。

I also found that the images do show (in a "broken" way, i.e. looks black not vibrant as a transition), but they disappear when alpha reaches 1.

推荐答案

这是一个部分解决方案:将资产目录中的图像切换为模板图像:

Here's a partial solution: switch your image in the asset catalog to be a template image:

至少这样你会看到的东西在设备上。

At least this way you'll see something on the device.

编辑实际上,Apple对此很明确。我引用 UIVisualEffectView.h 标题:

EDIT Actually, Apple is explicit about this. I quote from the UIVisualEffectView.h header:


UIImageView将需要其图像具有UIImageRenderingModeAlwaysTemplate的渲染模式收到适当的效果。

UIImageView will need its image to have a rendering mode of UIImageRenderingModeAlwaysTemplate to receive the proper effect.

这篇关于iOS 8活力图像未在设备上显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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