[英]How can I show/hide the status bar on a pageViewController using tap gesture (iOS8 / Swift)
通過查看類似問題的所有解決方案,我一直在嘗試通過輕擊手勢顯示/隱藏statusBar
。
我在plist中設置了View controller-based status bar appearance = NO
。
我在我的DataViewController
(頁面視圖控制器)和RootViewController
嘗試了以下代碼:
let app = UIApplication.sharedApplication()
app.setStatusBarHidden(true, withAnimation: UIStatusBarAnimation.Fade)
它不起作用。
這是嵌入在UITabBarController
,會有所作為嗎?
此外,我能夠從RootViewController
獲取以下內容來隱藏statusBar:
override func prefersStatusBarHidden() -> Bool {
return true
}
但是DataViewController
甚至沒有調用這個函數,只能以這種方式永久隱藏它,而不是打開/關閉它。
有任何想法嗎?
我在代碼中嘗試過,一切都適合我。 確保View controller-based status bar appearance
設置為NO 。 並且不需要覆蓋prefersStatusBarHidden()
。
如果您使用UIPageViewController
那么您應該在RootViewController
使用此代碼
如果你有一個navigationController
它也會隱藏它
在ViewDidLoad()
self.navigationController?.hidesBarsOnTap = true
並使用此方法根據是否隱藏navigationBar
來隱藏或顯示狀態欄
override func prefersStatusBarHidden() -> Bool {
if self.navigationController?.navigationBarHidden == true {
return true
}
else
{
return false
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.