title: Autolayout adding extra padding on top and bottom of UILabel iPhone 6/6+ when preferredMaxLayoutWidth is set
body: <p>I created a sample project to reproduce this.</p>
  
  <p>I've a xib file with an UILabel having a fixed top, leading and trailing constraint. I added a minHeight constraint and set the number  of lines to 0.</p>
  
  <p>I set the preferredMaxLayoutWidth to Automatic (checked in the xib file).</p>
  
  <p>In viewDidLoad, I've this:</p>
  
  <blockquote>
  <pre><code>self.myLabel.layer.borderColor = [[UIColor redColor] CGColor];
  self.myLabel.layer.borderWidth = 2.0f;
  </code></pre>
  </blockquote>
  
  <pre><code>self.myLabel.text = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
  </code></pre>
  
  <p>And when i run the simulator on iPhone 6 or 6+, I get this:</p>
  
  <p><img src="https://i.stack.imgur.com/Wju9B.png" alt="enter image description here"></p>
  
  <p>I've no idea where that top and bottom padding is coming from and it's proportional to the amount of characters in the UILabel is showing.</p>
  
  <p>Is there some magic setting I forgot ? It runs fine on iPhone 4" devices.</p>
  
  <p>Now if I don't set the preferredMaxLayoutWidth, it doesn't have the extra padding but this breaks my multi-lines in the UILabel. It cuts off the text. I did not use Size-Class.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>So I changed few things on my sample project to match the situation on my real project. I've added a tableView (with top, leading, bottom and trailing constraints set to its parent view). Each cell on the tableView has 4 labels. The top label has a top, leading and trailing constraint to the contentView of the cell and the subsequent labels have a vertical constraint to the label above it. Every label has a heightGreaterThan constraint set and a widthGreaterThan set.</p>
  
  <p>This is how it looks like without the preferredMaxLayoutWidth set (Notice how labels are capped to 1 line).
  <img src="https://i.stack.imgur.com/BGxam.png" alt="No preferredMaxLayoutWidth"></p>
  
  <p>With preferredMaxLayoutWidth. Now the UILabel shows the entire content but has a padding on top and bottom.
  <img src="https://i.stack.imgur.com/nUt9r.png" alt="With preferredMaxLayoutWidth but with top and bottom padding"></p>
  
  <p><strong>Edit2:</strong>
  Sample Project: <a href="https://www.dropbox.com/s/sdahx9njnsxiv98/MultiLineUILabel.zip?dl=1" rel="noreferrer">https://www.dropbox.com/s/sdahx9njnsxiv98/MultiLineUILabel.zip?dl=1</a></p>