title: How to get the dynamic height of UIView which contains two or more UILabels vertically?
body: <p>I am trying to find the dynamic height of a UIView at the run time. So, for this I calculated the run time height of UILabels in it and the constraint constants and add them all to get the desired height. But this doesn't seems to be the correct way of doing it, because in case I alter the count of UILabel or constraints in future then I do have to change the code to calculate the dynamic height. So, is there any way to get the height of UIView at run time with any number of labels and constraints in it?</p>
  <p><strong>MY CODE</strong></p>
  <p>Here <strong>uiview</strong> is UIView of which I need to calculate the dynamic height, <strong>label1</strong> and <strong>label2</strong> are the UILabels in which I inserted text programatically. <strong>height</strong> is a string extension to find dynamic height of UILabel. <strong>label1TopConstraint</strong>, <strong>label1BottonContraint</strong>, <strong>label2BottomConstraint</strong> are constraints IBOutlets.</p>
  <pre><code>let label1Height = label1.text!.height(withConstrainedWidth: label1.frame.width, font: label1.font)
  let label2Height = label2.text!.height(withConstrainedWidth: label2.frame.width, font: label2.font)
  uiviewHeight = label1Height + label2Height + label1TopConstraint.constant + label1BottonContraint.constant + label2BottomConstraint.constant
  </code></pre>