Skip to content

Instantly share code, notes, and snippets.

@maninp
Forked from tylerhargett/dynamic label size
Last active August 29, 2015 14:24
Show Gist options
  • Save maninp/02ca2d62c9c2f03556d9 to your computer and use it in GitHub Desktop.
Save maninp/02ca2d62c9c2f03556d9 to your computer and use it in GitHub Desktop.
- (CGFloat)heightOfCellWithIngredientLine:(NSString *)ingredientLine maxSize:(CGSize)max labelFont:(UIFont*)font
{
NSStringDrawingContext *context = [[NSStringDrawingContext alloc] init];
CGRect labelRect = [ingredientLine boundingRectWithSize:max
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:font}
context:context];
// return the calculated required height of the cell considering the label
return labelRect.size.height;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment