Ios 导航栏可以';不显示标题

Ios 导航栏可以';不显示标题,ios,swift,uikit,Ios,Swift,Uikit,我创建了一个UINavigationController对象,但它无法设置标题 class LogInSwitchingViewController: UINavigationController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.view.backgroun

我创建了一个UINavigationController对象,但它无法设置标题

class LogInSwitchingViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        self.view.backgroundColor = UIColor.white

        self.navigationItem.title = "This is title"
        self.navigationBar.tintColor = UIColor.black

        let vc1 = UIViewController()
        vc1.view.backgroundColor = UIColor.brown
        self.pushViewController(vc1, animated: true)
    }

您需要更新可见视图控制器的
标题
属性,而不是导航控制器本身:

let vc1 = UIViewController()
vc1.title = "This is title"
vc1.view.backgroundColor = UIColor.brown
self.pushViewController(vc1, animated: true)