Skip to content

Instantly share code, notes, and snippets.

@lonelytango
Last active August 29, 2015 14:20
Show Gist options
  • Save lonelytango/9ba75398336dd91685ab to your computer and use it in GitHub Desktop.
Save lonelytango/9ba75398336dd91685ab to your computer and use it in GitHub Desktop.
Method to replace sizeWithFont:constrainedToSize:lineBreakMode:
CGSize maximumLabelSize = CGSizeMake(tableView.width, MAXFLOAT);
NSStringDrawingOptions options = NSStringDrawingTruncatesLastVisibleLine |
NSStringDrawingUsesLineFragmentOrigin;
NSDictionary *attr = @{NSFontAttributeName: [UIFont systemFontOfSize:15]};
CGRect labelBounds = [string boundingRectWithSize:maximumLabelSize
options:options
attributes:attr
context:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment