Detecting iPhone 6/6+ screen sizes in point values

前端 未结 16 2337
独厮守ぢ
独厮守ぢ 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: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...
    
    }
    

提交回复
热议问题