2014-09-05 160 views
0

我想單擊一個按鈕來隱藏狀態欄。我曾嘗試過:動態隱藏狀態欄

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]; 

我對此沒有任何好運。我錯過了什麼嗎?

+0

可能重複:http://stackoverflow.com/questions/18059703/cannot-hide-status-bar-in-ios7和http://stackoverflow.com/questions/ 19067899 /如何隱藏狀態欄在編程方式在ios-7 – Aaron 2014-09-05 21:09:36

+0

是的,我只是希望有另一種方式。 – Shawn 2014-09-05 21:29:55

+1

查看此答案,以便在需要時進行更改:http://stackoverflow.com/a/18856079/772156 – hukir 2014-09-05 22:53:31

回答

2

簡單的方法是,轉到info.plist文件。添加行,「查看基於控制器的狀態欄外觀」並設置爲NO。檢查作爲答案

0

如果你想這樣做編程 試試這個。

覆蓋的funtion

-(BOOL) prefersStatusBarHidden { 
    return needHideStatusBar; 
} 

-(IBAction) checkStatus { 

    // do your judgment here 

    needHideStatusBar = YES; 
    if ([self 
     respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { 
     [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; 
    } 
}