How do I programmatically add a view right under the navigation bar?
问题 I'm trying to add a view to a UINavigationController with its top aligned with the navigation bar's bottom. I tried using constraints by adding the following to my UINavigationController subclass: override func viewDidAppear(_ animated: Bool) { self.label = UILabel() self.label?.translatesAutoresizingMaskIntoConstraints = false self.label?.backgroundColor = UIColor.red self.label?.text = "label text" self.view.addSubview(self.label!) let horConstraint = NSLayoutConstraint(item: label!,