Commit d3403347e5944987bc0e460324bda24271748aab

Authored by zhangxiaowen
1 parent b05b06d7

no message

CNLiveSettingModule/Classes/FontSIze/CNLiveMessageContentButton.h
@@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
7 // 7 //
8 8
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 -#import "CNLiveMessageFrame.h"  
11 -#import "CNLiveMessageModel.h" 10 +
  11 +@class CNLiveMessageFrame;
12 12
13 @interface CNLiveMessageContentButton : UIButton 13 @interface CNLiveMessageContentButton : UIButton
14 14
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageContentButton.m
@@ -8,6 +8,8 @@ @@ -8,6 +8,8 @@
8 8
9 #import "CNLiveMessageContentButton.h" 9 #import "CNLiveMessageContentButton.h"
10 #import "CNLiveBaseKit.h" 10 #import "CNLiveBaseKit.h"
  11 +#import "CNLiveMessageFrame.h"
  12 +#import "CNLiveMessageModel.h"
11 13
12 @interface CNLiveMessageContentButton() 14 @interface CNLiveMessageContentButton()
13 15
@@ -67,9 +69,12 @@ @@ -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
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 // 7 //
8 #define ChatMargin 10 //间隔 8 #define ChatMargin 10 //间隔
9 #define ChatIconWH 45 //头像宽高height、width 9 #define ChatIconWH 45 //头像宽高height、width
10 - 10 +#define ChatLineSpacing 6
11 #define ChatContentTop 15 //文本内容与按钮上边缘间隔 11 #define ChatContentTop 15 //文本内容与按钮上边缘间隔
12 #define ChatContentLeft 20 //文本内容与按钮左边缘间隔 12 #define ChatContentLeft 20 //文本内容与按钮左边缘间隔
13 #define ChatContentBottom 15 //文本内容与按钮下边缘间隔 13 #define ChatContentBottom 15 //文本内容与按钮下边缘间隔
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageFrame.m
@@ -29,7 +29,9 @@ @@ -29,7 +29,9 @@
29 CGFloat contentY = iconY; 29 CGFloat contentY = iconY;
30 30
31 CGSize maxSize = CGSizeMake(SCREEN_WIDTH-ChatIconWH*2-ChatMargin*2-(ChatContentLeft + ChatContentRight), CGFLOAT_MAX); 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 if ([_message.fromMe isEqualToString:@"1"]){ 36 if ([_message.fromMe isEqualToString:@"1"]){
35 contentX = iconX - contentSize.width - ChatContentLeft - ChatContentRight - ChatMargin; 37 contentX = iconX - contentSize.width - ChatContentLeft - ChatContentRight - ChatMargin;