您的位置:首页 > 产品设计 > UI/UE

获取iPhone各个版本屏幕大小

2016-04-22 10:56 537 查看
IOS的开发现在在屏幕的适配上比较麻烦,下面就来了解下各个iPhone的屏幕大小,获取屏幕大小和状态栏的代码如下:



//整个屏幕的大小
CGRect rc = [[UIScreen mainScreen] bounds];
NSLog(@"bounds x = %f, y = %f, width = %f, height = %f", rc.origin.x, rc.origin.y, rc.size.width, rc.size.height);
//可用区域的大小
CGRect rc1 = [UIScreen mainScreen].applicationFrame;
NSLog(@"applicationFrame x = %f, y = %f, width = %f, height = %f", rc1.origin.x, rc1.origin.y, rc1.size.width, rc1.size.height);
//状态栏的大小
CGRect barRc = [[UIApplication sharedApplication] statusBarFrame];
NSLog(@"statusBarFrame x = %f, y = %f, width = %f, height = %f", barRc.origin.x, barRc.origin.y, barRc.size.width, barRc.size.height);
现在就就将主流的iPhone手机屏幕打印出来

iPhone 4S   320x480    3.5‘

2016-04-22 10:25:56.437  bounds x = 0.000000, y = 0.000000, width = 320.000000, height = 480.000000
2016-04-22 10:25:56.438  applicationFrame x = 0.000000, y = 20.000000, width = 320.000000, height = 460.000000
2016-04-22 10:25:56.438  statusBarFrame x = 0.000000, y = 0.000000, width = 320.000000, height = 20.000000
iPhone 5   320x568    4.0’

2016-04-22 10:43:18.905  bounds x = 0.000000, y = 0.000000, width = 320.000000, height = 568.000000
2016-04-22 10:43:18.906  applicationFrame x = 0.000000, y = 20.000000, width = 320.000000, height = 548.000000
2016-04-22 10:43:18.906  statusBarFrame x = 0.000000, y = 0.000000, width = 320.000000, height = 20.000000
iPhone 5S   320x568   4.0‘

2016-04-22 10:45:06.661  bounds x = 0.000000, y = 0.000000, width = 320.000000, height = 568.000000
2016-04-22 10:45:06.662  applicationFrame x = 0.000000, y = 20.000000, width = 320.000000, height = 548.000000
2016-04-22 10:45:06.662  statusBarFrame x = 0.000000, y = 0.000000, width = 320.000000, height = 20.000000
iPhone 6   375x667   4.7’

2016-04-22 10:47:22.315  bounds x = 0.000000, y = 0.000000, width = 375.000000, height = 667.000000
2016-04-22 10:47:22.316  applicationFrame x = 0.000000, y = 20.000000, width = 375.000000, height = 647.000000
2016-04-22 10:47:22.316  statusBarFrame x = 0.000000, y = 0.000000, width = 375.000000, height = 20.000000
iPhone 6 Plus   414x736   5.5‘

2016-04-22 10:48:46.672  bounds x = 0.000000, y = 0.000000, width = 414.000000, height = 736.000000
2016-04-22 10:48:46.672  applicationFrame x = 0.000000, y = 20.000000, width = 414.000000, height = 716.000000
2016-04-22 10:48:46.673  statusBarFrame x = 0.000000, y = 0.000000, width = 414.000000, height = 20.000000
iPhone 6S   375x667   4.7’

2016-04-22 10:50:55.777  bounds x = 0.000000, y = 0.000000, width = 375.000000, height = 667.000000
2016-04-22 10:50:55.778  applicationFrame x = 0.000000, y = 20.000000, width = 375.000000, height = 647.000000
2016-04-22 10:50:55.778  statusBarFrame x = 0.000000, y = 0.000000, width = 375.000000, height = 20.000000
iPhone 6S Plus   414x736   5.5‘

2016-04-22 10:52:15.132  bounds x = 0.000000, y = 0.000000, width = 414.000000, height = 736.000000
2016-04-22 10:52:15.133  applicationFrame x = 0.000000, y = 20.000000, width = 414.000000, height = 716.000000
2016-04-22 10:52:15.133  statusBarFrame x = 0.000000, y = 0.000000, width = 414.000000, height = 20.000000
CGRect rc1 = [UIScreen mainScreen].applicationFrame;这个方法在IOS9.0以上已经过时了,建议我们使用CGRect rc = [[UIScreen mainScreen] bounds];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息