如何缩小从远程服务器加载非视网膜iPhone的视网膜图像?

Cam*_*oft 1 iphone scale uiimage ios retina-display

我必须从远程源为我的应用程序加载图标,图像为50x50px,以25x25px显示在设备上.

目前,图标在视网膜设备上显示正确的尺寸,但在非视网膜设备上显示尺寸的两倍.

仅供参考:远程信号源无法提供非视网膜图像.

如何在非视网膜设备上缩小UIImage,以便所有设备显示相同的大小?

A-L*_*ive 7

首先检查你是否有Retina显示屏

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2){
Run Code Online (Sandbox Code Playgroud)

那么你需要设置图像的比例选项:

UIImage * scaledImage = [UIImage alloc];
scaledImage = [[scaledImage initWithCGImage:[resourceImage CGImage] scale:2.0 orientation:UIImageOrientationUp] autorelease];
Run Code Online (Sandbox Code Playgroud)

然后我相信imageView应该缩放它并正确显示