Skip to content

Instantly share code, notes, and snippets.

@YGeorge
Created April 13, 2014 09:35
Show Gist options
  • Save YGeorge/10576558 to your computer and use it in GitHub Desktop.
Save YGeorge/10576558 to your computer and use it in GitHub Desktop.
ChatMessage *message = [chatMessages objectAtIndex:indexPath.row];
CGFloat topMargin = (indexPath.row == 0) ? 18 : 0;
CGRect stringRect = [message.text boundingRectWithSize:CGSizeMake(200, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{ NSFontAttributeName : [UIFont fontWithName:CHAT_CELL_FONT size:14] }
context:nil];
CGSize stringSize = CGRectIntegral(stringRect).size;
CGFloat bottomMargin = [self isMessageHasTail:indexPath.row] ? 30 : 20;
return stringSize.height + bottomMargin + topMargin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment