簡體   English   中英

Swift 隱藏導航欄

[英]Swift hide the navigation bar

我正在做一個項目,想在我的應用程序中隱藏導航欄。 我已經在 web 中找到了一些代碼來隱藏欄,但是當我隱藏它時,向后滑動 function 會禁用。 所以我不想有導航欄,但我想要回掃 function。

我已經嘗試過這段代碼:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    navigationController?.setNavigationBarHidden(true, animated: animated)
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    navigationController?.setNavigationBarHidden(false, animated: animated)
}

這段代碼也在這里:

self.navigationController?.navigationBar.isHidden = true

等等...

當您隱藏導航欄時,向后滑動到 go 將不起作用。 也許您想要我建議您的完全透明的導航欄,因為您可以使用這樣的安全區域限制視圖,並且您將向后滑動到 go。

    let navBarAppearance = UINavigationBarAppearance()
    navBarAppearance.configureWithTransparentBackground()
    navigationController?.navigationBar.standardAppearance = navBarAppearance
    navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
    navigationController?.navigationBar.compactAppearance = navBarAppearance
    self.navigationController?.navigationBar.prefersLargeTitles = false
    self.navigationController?.navigationBar.topItem?.title? = "Back"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM