Avoiding blended layers when using resizableImages on iOS

☆樱花仙子☆ 提交于 2019-12-07 01:54:25

问题


I'm trying to avoid blended layers on iOS to improve performance. However, I notice that the resizable image I'm using for the backgroundView of my UITableViewCell is being marked as a blended layer:

In fact, using any resizable image--even a JPEG with no transparency--caused layer blending, as seen in this screenshot where first a PNG and then a JPEG is used as a resizable image in a UIImageView. The only resizable image that didn't require a blended layer was a 1x1 pixel image, seen at the bottom:

Is there any way to avoid this? Core Animation profiling is imprecise art (atleast to me), but I think it's a main contributor to dropping to around 25 FPS when scrolling my table view.

Edit2: Upon more experimentation, I found that if I only vertically or horizontally stretched the images (either a PNG or JPG), they weren't marked as blended layers. However, upon even more experimentatio I think this may be because the images only stretched in one dimension are smaller. My image is not being treated as blended at 100x100, but it is at 150x100.


回答1:


I created a very wide image and only stretched it vertically. This did not require blended layers, and achieves the correct effect for my table view cell. This isn't ideal, but because of the small height it's still only 236 bytes for the retina image.



来源:https://stackoverflow.com/questions/14820185/avoiding-blended-layers-when-using-resizableimages-on-ios

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