You should avoid creating UIImage objects that are greater than 1024 x
1024 in size. Besides the large amount of memory such an image would
consume,you may run into problems when using the image as a texture
in OpenGL ES or when drawing the image to a view or layer. This size
restriction does not apply if you are performing code-based
manipulations,such as resizing an image larger than 1024 x 1024
pixels by drawing it to a bitmap-backed graphics context. In fact,you
may need to resize an image in this manner (or break it into several
smaller images) in order to draw it to one of your views.
我认为这意味着如果我们使用非方形图像,我们应该将它们分解成更小的图像?是否有任何具体的文件或解释,或者有任何经验提示吗?
谢谢阅读.
解决方法
这并不意味着您必须拥有方形图像,只是图像的宽度或高度不得超过2048(在新设备上再次为4096).如果您尝试这样做,我相信您的图像将呈现为黑色.
这曾经是所有没有CATiledLayer支持的UIViews的限制,但我相信他们现在会自动对足够大的视图进行平铺.如果您需要使用大于2048×2048的图像,则需要将其托管在CATiledLayer等中.
但记忆警告值得关注.图像以未压缩的形式存储在内存中,无论其来源如何,因此您需要查看每2048×2048图像16,777,216个字节(RGBA每像素4个字节).如果你不小心,这可以很快加起来.