如何检测视网膜高清显示?

UIScreen在iOS 8中有一个新的nativeScale属性,但文档对此没有nativeScale

 @property(nonatomic, readonly) CGFloat nativeScale 

还有一个scale财产,但文件说,视网膜显示2。

 @property(nonatomic, readonly) CGFloat scale 

我想知道是否有办法区分显示器。 我需要知道该设备是否有Retina HD显示器的原因是因为我想根据显示器请求不同大小的图像。

谢谢你的帮助!

下面的工作很好地检测iPhone6Plus上的显示types。

 if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 3.0) NSLog(@"Retina HD"); else NSLog(@"Non Retina HD"); 

检查下面的代码:

  CGRect screenBounds = [[UIScreen mainScreen] bounds]; CGFloat screenScale = [[UIScreen mainScreen] scale]; CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale); NSLog(@"WIDTH:%f",screenSize.height); NSLog(@"WIDTH:%f",screenSize.width); float height =screenSize.height; float width = screenSize.width; NSString *deviceType=@""; if (height==1136.000000 && width==640.000000) { deviceType =@"iPhone 5,5S and 5C Retina"; } if (height==1920.000000 && width==1080.000000) { deviceType =@"iPhone 6 Plus Retina Downsample"; } if (height==2208.000000 && width==1242.000000) { deviceType =@"iPhone 6 Plus Retina"; } if (height==1334.000000 && width==750.000000) { deviceType =@"iPhone 6 Retina"; } if (height==960.000000 && width==640.000000) { deviceType =@"iPhone 4 and 4S Retina"; } if (height==480.000000 && width==320.000000) { deviceType =@"iPhone 3g and 3gs Non retina "; } NSLog(@"Your Result:%@",deviceType); 

参考:

iPhone的资源