title: Programmatically Creating UILabel
body: <p>I know this should be very simple, but I've been really struggling with creating a UILabel programmatically and getting it to behave the way I would like.</p>
  
  <p>All I want is to be able to create a label, set the maximum attributes as far as height, width and font size, and then have the text get smaller AND/OR just truncate the text to accommodate long strings of text.</p>
  
  <p>Let's say that I want my label to have text that has a maximum width of 380, a maximum height of 20 and a maximum font size of 12. </p>
  
  <p>So here is what I have attempted to do to create such a label:</p>
  
  <pre><code>UILabel *fromLabel = [[UILabel alloc]initWithFrame:CGRectMake(91, 15, 0, 0)];
  fromLabel.text = [self fromSender];
  fromLabel.font = [UIFont fontWithName:ProximaNovaSemibold size:12]; //custom font
  fromLabel.numberOfLines = 1;
  fromLabel.baselineAdjustment = YES;
  fromLabel.adjustsFontSizeToFitWidth = YES;
  fromLabel.adjustsLetterSpacingToFitWidth = YES;
  fromLabel.size = [fromLabel.text sizeWithFont:fromLabel.font constrainedToSize:CGSizeMake(380, 20) lineBreakMode:NSLineBreakByTruncatingTail];
  fromLabel.minimumScaleFactor = MIN_SCALE_FACTOR;
  fromLabel.clipsToBounds = YES;
  fromLabel.backgroundColor = [UIColor clearColor];
  fromLabel.textColor = [UIColor blackColor];
  fromLabel.textAlignment = NSTextAlignmentLeft;
  [collapsedViewContainer addSubview:fromLabel];
  </code></pre>
  
  <p>Ok, so the label appears, but the text is larger than 12 and the height always comes out to be 21!? Even if I change the height and text size values to extreme sizes, this code creates a label of some fixed size that can't be adjusted. The only thing I can seem to make smaller is the width. </p>
  
  <p>I must be over looking something basic, but I really can't figure out how to get my desired result, nor do I understand why I'm getting the behavior that I am getting.</p>