Skip to content

Instantly share code, notes, and snippets.

@tylerhargett
Created March 13, 2014 21:14
Show Gist options
  • Save tylerhargett/9537106 to your computer and use it in GitHub Desktop.
Save tylerhargett/9537106 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