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 follo
Height of status bar is 20.You should consider status bar also while assigning y
of your label. Your viewDidAppear
should be
override func viewDidAppear(_ animated: Bool) {
self.label = UILabel(frame: CGRect(x: 0, y: navigationBar.frame.height+20, width: navigationBar.frame.width, height: 100))
self.label?.translatesAutoresizingMaskIntoConstraints = false
self.label?.backgroundColor = UIColor.red
self.label?.text = "label text"
self.view.addSubview(self.label!)
}
Hope it helps. Happy Coding!!