首页 > 代码库 > iOS 如何获取屏幕大小
iOS 如何获取屏幕大小
1 2 UIScreen *currentScreen = [UIScreen mainScreen]; 3 4 NSLog(@"applicationFrame.size.height = %f",currentScreen.applicationFrame.size.height); 5 6 NSLog(@"applicationFrame.size.width = %f",currentScreen.applicationFrame.size.width); 7 8 NSLog(@"applicationFrame.origin.x = %f",currentScreen.applicationFrame.origin.x); 9 10 NSLog(@"applicationFrame.origin.y = %f",currentScreen.applicationFrame.origin.y); 11 12 NSLog(@"bounds.x = %f",currentScreen.bounds.origin.x); 13 14 NSLog(@"bounds.y = %f",currentScreen.bounds.origin.y); 15 16 NSLog(@"bounds.height = %f",currentScreen.bounds.size.height); 17 18 NSLog(@"bounds.width = %f",currentScreen.bounds.size.width); 19 20 NSLog(@"brightness = %f",currentScreen.brightness);
更新:
iOS 9 之后:使用 [UIScreen mainScreen].bounds代替 [UIScreen mainScreen].applicationFrame
iOS 如何获取屏幕大小
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。