不透明 UIImageView 内图像的透明度
我经常使用“保存为网络和设备所用格式”功能从 Photoshop 导出 PNG 图像以在 iPhone 应用程序中使用。我总是选择透明度选项,即使图像没有透明部分。这是因为我认为如果图像没有透明区域,则不会有任何影响,并且选择该选项会更容易。
最近有人告诉我,通过这样做,UIImageView
的不透明属性实际上被忽略,因为 UIImage 将具有 Alpha 通道,对性能产生负面影响。
这是正确的吗?如果从 Photoshop 导出 PNG 时不需要透明度选项,我是否应该关闭它?
I often export PNG images from Photoshop for use in an iPhone app, using the Save For Web and Devices feature. I always leave the transparency option selected, even if there are no transparent parts to the image. This is because I assumed that it would have no effect if the image has no transparent areas, and it's easier to just leave the option selected.
I was told recently that by doing this, the opaque property of a UIImageView
is effectively ignored because the UIImage will have an alpha channel, having a negative impact on performance.
Is this correct? Should I turn off the transparency option if it's not needed when exporting PNGs from Photoshop?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了必须加载到
UIImageView
中的图像数据量之外,图像本身对UIImageView
或其opaque
属性的影响应该为零的image
属性。由于具有透明度的图像通常比不具有任何透明度的相同图像具有更大的数据量,因此在设置它时加载到UIImageView.image
中需要稍长的时间 (imageView.image = [UIImage imageNamed:@"myTransparentImage.png"];
)。当然,除非您在从 Photoshop 导出时使用不同的质量/压缩/格式/颜色深度/等。您可以使用 Instruments 应用程序和系统使用情况来验证所有这些,并查看每个不同图像的确切时间、I/O、内存等,< em>时间分析器和/或活动监视器模板。
The image itself should have zero effect on a
UIImageView
or itsopaque
property except for the amount of image data that has to be loaded into theUIImageView
'simage
property. Since, an image with transparency will usually have a larger amount of data than the same image without any transparency, it would take slightly longer for it to load into aUIImageView.image
when setting it (imageView.image = [UIImage imageNamed:@"myTransparentImage.png"];
). Unless, of course, you use a different quality/compression/format/color depth/etc when exporting from Photoshop.You can verify all of this and see the exact amount of time, I/O, memory, etc for each different image by using the Instruments App with the System Usage, Time Profiler, and/or Activity Monitor templates.