除了@ 2x之外还有其他方式让iOS知道图形是Retina Display准备好了吗?

Cy.*_*Cy. 2 cocoa-touch uikit uiimageview retina-display

我有一个Web服务,生成两个版本的图形; 一个用于标准显示,另一个用于Retina显示.

不幸的是我无法将@ 2x添加到文件名,因为我无法访问该代码.

有没有办法让iPhone知道从网上加载的是@ 2x图形?

Mar*_*rov 10

是的...当您将图像资源加载到UIImage中时,您可以自己设置该图像的比例,即.告诉iOS你的图像是否是@ 2x.

这是加载@ 2x图像的代码(在示例中来自文件,但您可以放置​​任何您想要的内容):

[[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path]] CGImage] scale:2.0 orientation:UIImageOrientationUp];
Run Code Online (Sandbox Code Playgroud)

这是加载低分辨率图像的代码:

[[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path]] CGImage] scale:1.0 orientation:UIImageOrientationUp];
Run Code Online (Sandbox Code Playgroud)

干杯,马林