2013-12-12 56 views
0

正如我們在iOS 7中所瞭解的那樣,狀態欄與視圖重疊但在iOS 6中不重疊。ios 6和ios 7在視圖中的相關性

我開發了iOS7的整個應用程序,現在我被要求爲它提供iOS6支持 但它只是一團糟。

,因爲我們在這個問題Overlaps the status bar on view iOS7看到有針對iOS 7的解決方案是像iOS6的

,但我可以把它相反的方式?並以某種方式使iOS 6的行爲像iOS7的狀態欄?

回答

1

你不能讓iOS 6狀態欄像iOS 7狀態欄一樣行動,它們是完全不同的設計。 iOS 7使用平板UI,而iOS 6則不使用。請仔細閱讀iOS 7 transition guide,以便更好地瞭解以及如何處理差異。

具體朝向狀態欄here是該文檔的一部分,告訴您如何處理它。

+0

感謝您的回答! –

1

簡答:不,你不能。

iOS 6 SDK不允許您像iOS 7那樣控制狀態欄。

你可以做的是調整大小,因此它不會在您的實際佈局

首先失去任何結構,你可以定義一個常量知道什麼時候它的iOS 7與否:

#define kIS_IOS_7 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) 

那麼在你的AppDelegate你可以改變導航欄外觀如下:

UIView *background = [[UIView alloc] init]; 
if (kIS_IOS_7) { 
    background.frame = CGRectMake(0, 0, 360, 64); 
} else { 
    background.frame = CGRectMake(0, 0, 360, 44); 
} 
background.backgroundColor = [UIColor blackColor]; // choose your color or image 
UIGraphicsBeginImageContext(background.frame.size); 
CGContextRef context = UIGraphicsGetCurrentContext(); 
[background.layer renderInContext:context]; 
UIImage *backgroundImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

[[UINavigationBar appearance] setBackgroundImage:backgroundImage 
            forBarMetrics:UIBarMetricsDefault]; 
+0

所以我不能使狀態欄是transperent並將我的整個視圖範圍原點y移動到-20? –

+0

@ user2957713不在iOS 6上沒有抱歉。我提供的指南中包含了您在支持iOS 6和iOS 7方面可能遇到的所有問題。還有一些必須和應該在那裏,如果支持兩者,您可能需要閱讀。 – Popeye

+0

好吧,似乎我會有難的時間:( 感謝您的回答 –