How do I programmatically add a view right under the navigation bar?

前端 未结 6 958
轻奢々
轻奢々 2021-02-04 11:25

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

6条回答
  •  长发绾君心
    2021-02-04 11:52

    Replace this

    self.label = UILabel(frame: CGRect(x: 0, y: navigationBar.frame.height, width: 300, height: 100))
    

    with

    self.label = UILabel(frame: CGRect(x: 0, y: 64, width: 300, height: 100))
    

    naviagtion bar & status bar together has a height of 64. Make it the y position

提交回复
热议问题