title: Why is this UILabel with NSAttributedString not showing?
body: <p>I am attempting to create a key for a chart, and I need to have a string followed by a colored box, then another string following this. However, the text is not showing up when attempting this. I haven't worked with attributed strings before, so it may be something obvious. Thanks!</p>
  
  <pre><code>UILabel *titleLabel = (UILabel*) [cell viewWithTag:101];
  UIView *myBox  = [[UIView alloc] initWithFrame:CGRectMake(1, 1, 30, 30)];
  myBox.backgroundColor = [UIColor blueColor];
  
  NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"test string"];
  NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
  textAttachment.image = [self imageWithView:myBox];
  
  CGFloat oldWidth = textAttachment.image.size.width;
  
  CGFloat scaleFactor = oldWidth / (titleLabel.frame.size.width - 10);
  textAttachment.image = [UIImage imageWithCGImage:textAttachment.image.CGImage scale:scaleFactor orientation:UIImageOrientationUp];
  NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
  [attributedString replaceCharactersInRange:NSMakeRange(6, 1) withAttributedString:attrStringWithImage];
  titleLabel.attributedText = attributedString;
  </code></pre>