iOS 如何获取屏幕大小

时间:2021-10-11 05:22:47
     UIScreen *currentScreen = [UIScreen  mainScreen];

     NSLog(@"applicationFrame.size.height = %f",currentScreen.applicationFrame.size.height);

     NSLog(@"applicationFrame.size.width = %f",currentScreen.applicationFrame.size.width);

     NSLog(@"applicationFrame.origin.x = %f",currentScreen.applicationFrame.origin.x);

     NSLog(@"applicationFrame.origin.y = %f",currentScreen.applicationFrame.origin.y);

     NSLog(@"bounds.x = %f",currentScreen.bounds.origin.x);

     NSLog(@"bounds.y = %f",currentScreen.bounds.origin.y);

     NSLog(@"bounds.height = %f",currentScreen.bounds.size.height);

     NSLog(@"bounds.width = %f",currentScreen.bounds.size.width);

     NSLog(@"brightness = %f",currentScreen.brightness);

更新:

iOS 9 之后:使用 [UIScreen  mainScreen].bounds代替 [UIScreen  mainScreen].applicationFrame