title: Adjust UIButton font size to width
body: <p>I have the following code:</p>
  
  <pre><code>UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  button.frame = CGRectMake(0.0, 0.0, 25, 25);
  
  [[button layer] setCornerRadius:5.0f];
  [[button layer] setMasksToBounds:YES];
  [[button layer] setBackgroundColor:[[UIColor redColor] CGColor]];
  [button.titleLabel setFrame:CGRectMake(0,0, 25, 25)];
  
  [button setTitle:[NSString stringWithFormat:@"%@", [[topics objectAtIndex:indexPath.row] unread]] forState:UIControlStateNormal];
  </code></pre>
  
  <p>The issue is that when the string in the text is not long, it shows fine (1-2 digit). However, when it's quite long (3++ digit), all I can see is a red button, with no text inside. How do I adjust this?</p>
  
  <p>I don't think that:</p>
  
  <pre><code>[button.titleLabel setAdjustsFontSizeToFitWidth:YES];
  </code></pre>
  
  <p>does the job, right?</p>