title: UILabel's height is to big for it's width
body: <p>As you can see right here, this is a UILabel with random text:</p>
  
  <p><a href="https://i.stack.imgur.com/r3qIr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r3qIr.png" alt="enter image description here"></a></p>
  
  <p>The height of that UILabel's text is too big. I just want the height to be adapted from what it is needed to be, for every different content and size of the width. Adding this extensions:</p>
  
  <pre><code>extension UILabel{
  
      func requiredHeight() -&gt; CGFloat{
  
          let label:UILabel = UILabel(frame: CGRect(0, 0, self.frame.width, CGFloat.greatestFiniteMagnitude))
          label.numberOfLines = 0
          label.lineBreakMode = NSLineBreakMode.byWordWrapping
          label.font = self.font
          label.text = self.text
  
          label.sizeToFit()
  
          return label.frame.height
      }
  }
  
  extension CGRect{
      init(_ x:CGFloat,_ y:CGFloat,_ width:CGFloat,_ height:CGFloat) {
          self.init(x:x,y:y,width:width,height:height)
      }
  }
  </code></pre>
  
  <p>are not working aswell... Is this possible to do in Storyboard? I tried setting an aspect ratio to it, but when programmatically making the label larger this fails. Is there an easy way to set the height of a UILabel to match it's content, and maybe even in storyboard? Because of the height is not corresponding with what it is needed to be, my whole layout is screwing up. The UILabel needs to be for example 10 points from the top layout. Because the height is to big, the UILabel is setting itself far more below than needed when running it on a different device than the settee layout in storyboard.</p>