title: UIButton that resizes to fit its titleLabel
body: <p>I have a <code>UIButton</code> that I add to my view controller's view in a storyboard. I add centering constraints to position it and leading space constraints to limit its width. In code I add:</p>
  
  <pre><code>self.button.titleLabel.numberOfLines = 0;
  self.button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
  [self.button setTitle:@"A real real real real real real real real long long name." forState:UIControlStateNormal];
  self.button.backgroundColor = [UIColor redColor];
  self.button.titleLabel.backgroundColor = [UIColor blueColor];
  </code></pre>
  
  <p>The result is shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/1k3od.png" alt="enter image description here"></p>
  
  <p>I want the button to size to its content. How can I do this?</p>
  
  <p>I've tried  </p>
  
  <pre><code>[self.button sizeToFit];
  </code></pre>
  
  <p>and I've tried setting the content hugging and compression resistance autolayout constraints priorities to required.</p>
  
  <p>I've also tried explicitly setting the <code>contentEdgeInsets</code> and <code>titleEdgeInsets</code> to <code>UIEdgeInsetsZero</code> and calling <code>invalidateIntrinsicContentSize</code>. </p>
  
  <p>I've also noticed that if I place newline characters in the title string, the button does seem to resize to fit its content.</p>
  
  <p>I'm running on Xcode 6 and iOS 8 on the iPhone 6 Simulator.</p>