text: Q:
  
  Calculating number of lines of dynamic UILabel (iOS7)
  
  There are many solutions to this questions arround but couldn't find non-deprecated one.
  I have an UILabel with mode WordWrap and fixed width of, let's say 250. Lines are set to 0.
  Here is what I tried:
  UILabel *contentLabel = (UILabel*)[contentView viewWithTag:10];
  CGSize size = [contentLabel.text sizeWithFont:contentLabel.font forWidth:contentLabel.frame.size.width lineBreakMode:NSLineBreakByWordWrapping];
  NSLog(@"Label's height is: %d", size.height);
  
  The output of height param is always 20 (so it's like one line), while te text is like 30 lines long.
  I need that for UIScrollView purposes.
  
  A:
  
  Use suggested in documentation method : 
  - (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(NSDictionary *)attributes context:(NSStringDrawingContext *)context NS_AVAILABLE_IOS(7_0);
  
  E.g.
      CGSize maxSize = CGSizeMake(self.label.frame.size.width, MAXFLOAT);
  
      CGRect labelRect = [self.label.text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.label.font} context:nil];
  
      NSLog(@"size %@", NSStringFromCGSize(labelRect.size));
  
  A:
  
  I was having trouble using boundingRectWithSize directly on my UILabel's attributedText — it was not accounting for the wrap to multiple lines, (the returned height was always 17.5). To work around this, I had to use boundingRectWithSize on the UILabel's text property and pass in the attributes dictionary separately (and not via [self.myLabel.attributedText attributesAtIndex:0 effectiveRange:nil]).
  CGRect labelSize = CGRectIntegral([self.myLabel.text     
      boundingRectWithSize:CGSizeMake(self.myLabel.frame.size.width, MAXFLOAT) 
      options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading
      attributes:@{NSFontAttributeName:self.myLabel.font, 
      NSParagraphStyleAttributeName:paragraphStyle} context:nil]);
  
  