iOS 8 vibrancy image not showing on device

寵の児 提交于 2019-12-20 03:44:10

问题


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):

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

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.

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.

Many thanks!!!

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).

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.


回答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.

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

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



来源:https://stackoverflow.com/questions/30541355/ios-8-vibrancy-image-not-showing-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!