【发布时间】:2018-02-14 22:56:40
【问题描述】:
这是我为自定义导航控制器所做的。我在 viewDidLoad 方法中添加了这段代码。
import UIKit
class Login: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigatonBar()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func navigatonBar(){
let codedLabel:UILabel = UILabel()
codedLabel.frame = CGRect(x: 0, y:-45, width: self.view.frame.width, height: 200)
codedLabel.textAlignment = .center
codedLabel.text = "Login"
codedLabel.textColor = .white
codedLabel.font=UIFont.systemFont(ofSize: 22)
let navigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width,height: 75))
navigationBar.backgroundColor = UIColor.red
navigationBar.isTranslucent = true
navigationBar.barTintColor = .red
self.view.addSubview(navigationBar)
self.view.addSubview(codedLabel)
}
}
但我在导航中看到一条黑线
【问题讨论】:
-
能否提供更多上下文
-
是的.. 我添加了更多行
-
所以你有一个自定义 UINavigationController 并添加第二个 UINavigationBar 作为子视图?请提供所有导航控制器代码。
-
我的视图控制器中没有其他代码
-
从您的模拟器中发布屏幕截图以查看您所引用的内容可能是个好主意。