![](/img/trans.png)
[英]Swift: Tableview scrolls under navigation bar but over status bar?
[英]Navigation bar not showing over TableView
我無法解釋為什么此代碼無法正常工作。 出於某種原因,導航欄是半透明的,並且tableView的內容正在其上滾動。
這是按鈕的代碼
let outlineViewController = OutlineTableviewController()
outlineViewController.pdfOutlineRoot = pdfoutline
outlineViewController.delegate = self
let nav = UINavigationController(rootViewController: outlineViewController)
self.present(nav, animated: true, completion:nil)
這是tableView的代碼
super.viewDidLoad()
let newBackButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.plain, target: self, action: #selector(dismissView))
self.navigationItem.rightBarButtonItem = newBackButton
navigationController?.navigationBar.backgroundColor = UIColor(red:0.00, green:0.51, blue:0.78, alpha:1.0)
self.tableView.dataSource = self
self.tableView.delegate = self
tableView?.register(UINib(nibName: "OutlineTableViewCell", bundle: nil),
forCellReuseIdentifier: "OutlineTableViewCell")
}
結果如下:不顯示背景色,表格位於導航欄下方。
我想念什么?
謝謝trungduc的回復。
在花了幾個小時試圖找出問題所在之后,我終於能夠通過更改根視圖中的顏色來解決此問題。
let nav = UINavigationController(rootViewController: oulineViewController)
nav.navigationBar.backgroundColor = UIColor(red:0.00, green:0.51, blue:0.78, alpha:1.0)
self.present(nav, animated: true, completion:nil)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.