title: Calculating UILabel Text Size
body: <p>I am drawing <code>UILabels</code> programmatically. They get their sizes from a database. So I cannot just use <code>sizeToFit</code>. I have already implemented a function that redraws <code>UILabels</code> with a passed ratio. So all I need to find is the text in <code>UILabel</code> from my view that would require the maximum ratio to redraw <code>UILabels</code>.
  So finally I need to do something like this:</p>
  
  <pre><code>    double ratio = 1.00;
      for (UILabel* labels in sec.subviews) {
  
          float widthLabel = labels.frame.size.width;
          float heightLabel = labels.frame.size.height;
          float heightText = //get the text height here
          float widthText = //get the text width here
          if (widthLabel &lt; widthText) {
              ratio = MAX(widthText/widthLabel,ratio);
          }
          if (heightLabel &lt; heightText) {
              ratio = MAX(heightText/heightLabel, ratio);
          }
      }
      //redraw UILabels with the given ratio here
  </code></pre>
  
  <p>So how can I get the height and width size of a text, as some of my text do not fit into the label I cannot simply use label bounds? I am using Xcode 5 and iOS 7.</p>