title: How to align baselines of text in UILabels with different font sizes on iOS?
body: <p>I need to align the baselines of text in UILabels. What I'm currently doing is I'm aligning the baselines of UILabels containing the text, and when the text font size in two labels is different, this results in aligned UILabels baseline but misaligned text baseline (misaligned by a small margin, but still misaligned). The labels are included in a custom UIView subclass, therefore <code>self</code> refers to the encompassing UIView.</p>
  
  <p>here is the relevant code</p>
  
  <pre><code>[self.mySmallLabel sizeToFit];
  [self.myBigLabel sizeToFit];
  
  self.mySmallLabel.frame = CGRectMake(0,     
                                       self.bounds.size.height - self.mySmallLabel.bounds.size.height, 
                                       self.mySmallLabel.bounds.size.width, 
                                       self.mySmallLabel.bounds.size.height);
  
  self.myBigLabel.frame = CGRectMake(self.mySmallLabel.frame.origin.x + self.mySmallLabel.bounds.size.width, 
                                     self.bounds.size.height - self.myBigLabel.bounds.size.height, 
                                     self.myBigLabel.bounds.size.width, 
                                     self.myBigLabel.bounds.size.height);
  [self.mySmallLabel sizeToFit];
  [self.myBigLabel sizeToFit];
  </code></pre>
  
  <p>This code results in the aligment in the image linked below.</p>
  
  <p><img src="https://i.stack.imgur.com/uRmyP.png" alt="Misalignemnt"></p>
  
  <p>As you can see, even though the UILabel baselines are aligned, the baselines of the text is misaligned by a small margin. How can I align the baselines of text dynamically (because font sizes might change at runtime)?</p>