美文网首页
识别设备是否为Retina显示

识别设备是否为Retina显示

作者: 4164fccdcf1c | 来源:发表于2017-11-17 10:11 被阅读12次

    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;
    
    }
    

    相关文章

      网友评论

          本文标题:识别设备是否为Retina显示

          本文链接:https://www.haomeiwen.com/subject/vavdvxtx.html