Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. [txt drawWithRect: options: attributes: context:]
  2.  
  3. + (CGSize)textSizeForText:(NSString *)txt
  4. {
  5. CGFloat width = [UIScreen mainScreen].applicationFrame.size.width * 0.75f;
  6. CGFloat height = MAX([JSBubbleView numberOfLinesForMessage:txt],
  7. [txt numberOfLines]) * [JSMessageInputView textViewLineHeight];
  8.  
  9.  
  10. return [txt sizeWithFont:[JSBubbleView font]
  11. constrainedToSize:CGSizeMake(width - kJSAvatarSize, height + kJSAvatarSize)
  12. lineBreakMode:NSLineBreakByWordWrapping];
  13.  
  14. }
  15.  
  16. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  17. paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
  18.  
  19. CGRect textRect = [text boundingRectWithSize:CGSizeMake(width - kJSAvatarSize, height + kJSAvatarSize)
  20. options:NSStringDrawingUsesLineFragmentOrigin
  21. attributes:@{NSParagraphStyleAttributeName: paragraphStyle.copy}
  22. context:nil];
  23.  
  24. return textRect.size;
  25.  
  26. return ([text boundingRectWithSize:CGSizeMake(width - kJSAvatarSize, height + kJSAvatarSize)
  27. options:NSStringDrawingUsesLineFragmentOrigin
  28. attributes:@{NSParagraphStyleAttributeName: paragraphStyle.copy}
  29. context:nil]).size;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement