IOS的開發現在在螢幕的适配上比較麻煩,下面就來了解下各個iPhone的螢幕大小,擷取螢幕大小和狀态欄的代碼如下:
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIyVGduV2QvwVe0lmdhJ3ZvwFM38CXlZHbvN3cpR2Lc1TPB10QGtWUCpEMJ9CXsxWam9CXwADNvwVZ6l2c052bm9CXUJDT1wkNhVzLcRnbvZ2LcZXUYpVd1kmYr50MZV3YyI2cKJDT29GRjBjUIF2LcRHelR3LcJzLctmch1mclRXY39TO5cTOzcTN4EjMyQDM2EDMy8CX0Vmbu4GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.jpg)
//整個螢幕的大小
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];