Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [txt drawWithRect: options: attributes: context:]
- + (CGSize)textSizeForText:(NSString *)txt
- {
- CGFloat width = [UIScreen mainScreen].applicationFrame.size.width * 0.75f;
- CGFloat height = MAX([JSBubbleView numberOfLinesForMessage:txt],
- [txt numberOfLines]) * [JSMessageInputView textViewLineHeight];
- return [txt sizeWithFont:[JSBubbleView font]
- constrainedToSize:CGSizeMake(width - kJSAvatarSize, height + kJSAvatarSize)
- lineBreakMode:NSLineBreakByWordWrapping];
- }
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
- CGRect textRect = [text boundingRectWithSize:CGSizeMake(width - kJSAvatarSize, height + kJSAvatarSize)
- options:NSStringDrawingUsesLineFragmentOrigin
- attributes:@{NSParagraphStyleAttributeName: paragraphStyle.copy}
- context:nil];
- return textRect.size;
- return ([text boundingRectWithSize:CGSizeMake(width - kJSAvatarSize, height + kJSAvatarSize)
- options:NSStringDrawingUsesLineFragmentOrigin
- attributes:@{NSParagraphStyleAttributeName: paragraphStyle.copy}
- context:nil]).size;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement