我有一个生成两个图形版本的网络服务;一个用于正常显示,另一个用于 Retina 显示。
不幸的是,我无法将@2x 添加到文件名,因为我无权访问该代码。
有什么方法可以让 iPhone 知道从 Web 加载的内容是 @2x 图形?
我有一个生成两个图形版本的网络服务;一个用于正常显示,另一个用于 Retina 显示。
不幸的是,我无法将@2x 添加到文件名,因为我无权访问该代码。
有什么方法可以让 iPhone 知道从 Web 加载的内容是 @2x 图形?
是的……当您将图像资源加载到 UIImage 中时,您可以自己设置该图像的比例,即。告诉 iOS 你的图片是否为@2x。
这是加载 @2x 图像的代码(在示例中来自文件,但您可以放置任何您想要的内容):
[[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path]] CGImage] scale:2.0 orientation:UIImageOrientationUp];
这是加载低分辨率图像的代码:
[[UIImage alloc] initWithCGImage:[[UIImage imageWithData:[NSData dataWithContentsOfFile:path]] CGImage] scale:1.0 orientation:UIImageOrientationUp];
干杯,马林