Detecting iPhone 6/6+ screen sizes in point values

前端 未结 16 2144
独厮守ぢ
独厮守ぢ 2020-11-29 15:44

Given the newly announced iPhone 6 screen sizes:

iPhone 6: 1334h * 750w @2x (in points: 667h * 375w)
iPhone 6+: 1920 * 1080 @3x (in points: 640h * 360w)


        
相关标签:
16条回答
  • 2020-11-29 16:12

    Check the updated list on wiki , there I got 7,2 for iPhone 6 and 7,1 for iPhone 6 plus.

    0 讨论(0)
  • 2020-11-29 16:12

    An interesting thing to remember when reading screen sizes on my iPhone 6 Plus was that when you have it set to "Zoomed" mode it will show up as a the iPhone 6 height (667) and when you have it set to "Standard" it will show up as (736). Shouldn't really matter, but if you specifically wanted to know the device type for some reason ( Maybe Reporting ), this could fool you.

    See this.

    0 讨论(0)
  • 2020-11-29 16:13

    If you prefer macros here are the ones, that you can use to differentiate between the iPhone models. These are based on the point values.

    #define IS_IPHONE_4 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)480) < DBL_EPSILON)
    #define IS_IPHONE_5 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
    #define IS_IPHONE_6 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)667) < DBL_EPSILON)
    #define IS_IPHONE_6_PLUS (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)736) < DBL_EPSILON)
    
    0 讨论(0)
  • 2020-11-29 16:13

    This is what I use in my app with iOS 8:

    window=[[[UIApplication sharedApplication] windows] firstObject];
    
    NSLog(@"screenHeight=%f width=%f",window.frame.size.height,window.frame.size.width);
    
    if (window.frame.size.height == 480) {
    
            do stuff here... 
        }
    

    Prior to Xcode6 / iOS 8, I used this, but screen bounds does not work properly with the resizable simulator or at least it didn't in the Xcode6 betas...

    CGRect screenBounds=[[UIScreen mainScreen] bounds];
    
    if (screenBounds.size.height >= 568) {
    
    do stuff here...
    
    }
    
    0 讨论(0)
提交回复
热议问题