//目的:用於iOS7和iOS6適配,和保留以前的座標編碼習慣,不用刻意加減 /*方法1: *1。在vc中重寫viewDidLayoutSubviews方法 *2。是用下面2個方法之一; *3。frame爲ios6風格,狀態欄和導航欄爲平鋪 *4。bounds爲ios7風格,狀態欄和導航欄爲覆蓋 *5。優勢,全部subview的座標都一ios6的標準進行編寫,支持push和present *6。缺點,在push中每一個vc都須要重寫viewDidLayoutSubviews方法; */ void IOS7ToIOS6ofFrame(UIViewController *vc); void IOS7ToIOS6ofBounds(UIViewController *vc); void IOS7ToIOS6ofFrame(UIViewController *vc) { if (IsIOS7) { CGRect rect = vc.view.frame; vc.view.frame = CGRectMake((rect.origin.x), (rect.origin.y+(IsIOS7?vc.topLayoutGuide.length:0)), (CGRectGetWidth(rect)), (CGRectGetHeight(rect)-(IsIOS7?vc.topLayoutGuide.length:0))); } } void IOS7ToIOS6ofBounds(UIViewController *vc) { if (IsIOS7) { CGRect rect = vc.view.bounds; if (rect.origin.y != -1*vc.topLayoutGuide.length) { vc.view.bounds = CGRectMake((rect.origin.x), (rect.origin.y+(IsIOS7?vc.topLayoutGuide.length*(-1):0)), (CGRectGetWidth(rect)), (CGRectGetHeight(rect))); } } } /*方法2: *1.在vc的init或viewdidload中使用IOS7宏便可; *2.狀態欄和導航欄爲平鋪 *3.優勢:全部subview的座標都一ios6的標準進行編寫,支持push,背景frame值同ios6 *4.缺點:在push中每一個vc都須要寫,不支持present; */ #define IOS7 if([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=7)\ {self.extendedLayoutIncludesOpaqueBars = NO;\ self.modalPresentationCapturesStatusBarAppearance =NO;\ self.edgesForExtendedLayout = UIRectEdgeNone;} /*方法3: *1.使用self.navigationController.navigationBar.translucent =NO; *2.狀態欄和導航欄爲平鋪 *3.優勢:全部subview的座標都一ios6的標準進行編寫,支持push,背景frame值同ios6,只須要設置一次 *4.缺點:必須有nav;對於present的vc必須爲nav */ /*方法4: *1.從新定義CGRECT; *2.狀態欄和導航欄爲覆蓋 *3.優勢:隨時能夠用 */ #define IsIOS7 ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=7) #define CGRECT_NO_NAV(x,y,w,h) CGRectMake((x), (y+(IsIOS7?20:0)), (w), (h)) #define CGRECT_HAVE_NAV(x,y,w,h) CGRectMake((x), (y+(IsIOS7?64:0)), (w), (h))
http://www.xiaoyaoli.com/?p=1167html
iOS6適配iOS7 iOS 適配 IOS7 UI適配ios
iOS開發實用技巧——屏幕適配研究shell
iOS 7 教程:定製iOS 7中的導航欄和狀態欄xcode
iOS6適配iOS7iphone
iOS7適配問題總結 post
http://blog.sina.com.cn/s/blog_aeb8e4450101bjxc.htmlui
xcode 5與ios 7的屏幕適配問題編碼
#define DEVICE_IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568) float height = DEVICE_IS_IPHONE5?568:480; if (height == 568) { // 4" } else { // 3" } http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution/16914009#16914009