title: UILabel SizetoFit After Specifying Number of Lines?
body: <p>I would like to create a UILabel programmatically after specifying the number of lines. I am using Swift. I have the following code: </p>
  
  <pre><code>let newLabel = UILabel()
  newLabel.text = "Hello There"
  newLabel.font = UIFont.systemFont(ofSize: 16)
  newLabel.numberOfLines = 2
  newLabel.lineBreakMode = .byWordWrapping
  newLabel.sizeToFit()
  newLabel.frame.origin.x = 100
  newLabel.frame.origin.y = 500
  view.addSubview(newLabel)
  </code></pre>
  
  <p>The problem is that the label has the text on one line, rather than two lines. I have to use sizeToFit because the fontSize is actually dynamic (it is not always 16). How can I make sure that the label is 2 lines? Thanks. </p>