识别设备是否为Retina显示
2017-11-17 本文已影响12人
4164fccdcf1c
The natural scale factor associated with the screen. (read-only)
@property(nonatomic, readonly) CGFloat scale
Discussion
This value reflects the scale factor needed to convert from the default logical coordinate space into the device coordinate space of this screen. The default logical coordinate space is measured using points. For standard-resolution displays, the scale factor is 1.0 and one point equals one pixel. For Retina displays, the scale factor is 2.0 and one point is represented by four pixels.
+ (BOOL) isRetinaDisplay {
int scale = 1.0;
UIScreen *screen = [UIScreen mainScreen];
if([screen respondsToSelector:@selector(scale)])
scale = screen.scale;
if(scale == 2.0f) return YES;
else return NO;
}