How to resize Title in a navigation bar dynamically

前端 未结 9 1932
慢半拍i
慢半拍i 2020-12-03 01:24

I have some views that show up in a navigation controller. Two of these views have a longer title for the navigation bar.

The problem is that when the title is too

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 02:21

    In case you have a view added into titleView, and you want to resize the view, you can use this code (Swift 3):

    self.translatesAutoresizingMaskIntoConstraints = false
    self.layoutIfNeeded()
    self.sizeToFit()
    self.translatesAutoresizingMaskIntoConstraints = true
    

提交回复
热议问题