There is a UIView on which the UILabel is located, and the numberOfLines property is set to zero. How to resize a UIView if the text in the label is more than one line.

let someView = NSBundle.mainBundle().loadNibNamed("foo", owner: self, options: nil)[0] as! foo someView.label.text = text 
  • Use not UIView, but UIScrollView, thus the text can be scrolled. Here is an example in the video . - Andrii Moisol
  • @AndriiMoisol I do not need to scroll it, it should be a label that expands the container - user204104
  • Use constraints - Maxim Bogdanov

1 answer 1

Set the constraints for the view (or frame), then set the constraints for the label, and then, depending on how many lines, increase the desired constraint (or height for the frame).