Commit d3403347e5944987bc0e460324bda24271748aab
1 parent
b05b06d7
no message
Showing
4 changed files
with
14 additions
and
7 deletions
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageContentButton.h
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageContentButton.m
| ... | ... | @@ -8,6 +8,8 @@ |
| 8 | 8 | |
| 9 | 9 | #import "CNLiveMessageContentButton.h" |
| 10 | 10 | #import "CNLiveBaseKit.h" |
| 11 | +#import "CNLiveMessageFrame.h" | |
| 12 | +#import "CNLiveMessageModel.h" | |
| 11 | 13 | |
| 12 | 14 | @interface CNLiveMessageContentButton() |
| 13 | 15 | |
| ... | ... | @@ -67,9 +69,12 @@ |
| 67 | 69 | |
| 68 | 70 | } |
| 69 | 71 | |
| 70 | - self.content.hidden = NO; | |
| 71 | - self.content.text = message.content; | |
| 72 | - self.content.font = UIFontCNMake(15); | |
| 72 | + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:message.content]; | |
| 73 | + [attributedString addAttribute:NSFontAttributeName value:UIFontCNMake(15) range:NSMakeRange(0, message.content.length)]; | |
| 74 | + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init]; | |
| 75 | + [paragraphStyle setLineSpacing:ChatLineSpacing]; | |
| 76 | + [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, message.content.length)]; | |
| 77 | + self.content.attributedText = attributedString; | |
| 73 | 78 | |
| 74 | 79 | } |
| 75 | 80 | ... | ... |
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageFrame.h
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageFrame.m
| ... | ... | @@ -29,7 +29,9 @@ |
| 29 | 29 | CGFloat contentY = iconY; |
| 30 | 30 | |
| 31 | 31 | CGSize maxSize = CGSizeMake(SCREEN_WIDTH-ChatIconWH*2-ChatMargin*2-(ChatContentLeft + ChatContentRight), CGFLOAT_MAX); |
| 32 | - CGSize contentSize = [_message.content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:UIFontCNMake(15)} context:nil].size; | |
| 32 | + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init]; | |
| 33 | + [paragraphStyle setLineSpacing:ChatLineSpacing]; | |
| 34 | + CGSize contentSize = [_message.content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:UIFontCNMake(15),NSParagraphStyleAttributeName:paragraphStyle} context:nil].size; | |
| 33 | 35 | |
| 34 | 36 | if ([_message.fromMe isEqualToString:@"1"]){ |
| 35 | 37 | contentX = iconX - contentSize.width - ChatContentLeft - ChatContentRight - ChatMargin; | ... | ... |