Commit 8b5baec10777c2b9fb96b95e30513c0db2ccb841

Authored by zhangxiaowen
1 parent 5171e35a

no message

CNLiveSettingModule/Classes/FontSIze/CNLiveFontSettingController.m
... ... @@ -16,7 +16,7 @@
16 16 #import "CNLiveMessageModel.h"
17 17 #import "CNLiveMessageCell.h"
18 18  
19   -@interface CNLiveFontSettingController ()<UIGestureRecognizerDelegate, UITableViewDelegate, UITableViewDataSource, CNLiveSettingNavigationBarDelegate>
  19 +@interface CNLiveFontSettingController ()<UITableViewDelegate, UITableViewDataSource, CNLiveSettingNavigationBarDelegate>
20 20 @property (nonatomic, strong) CNLiveSettingNavigationBar *navigationBar;
21 21 @property (nonatomic, strong) UITableView *tableView;
22 22 @property (nonatomic, strong) NSMutableArray *data;
... ... @@ -107,7 +107,7 @@
107 107 [_slider addTarget:self action:@selector(sliderTouchUp:) forControlEvents:UIControlEventTouchUpInside];
108 108  
109 109 self.tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
110   - _tapGesture.delegate = self;
  110 +// _tapGesture.delegate = self;
111 111 [self.slider addGestureRecognizer:self.tapGesture];
112 112 UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width-70-30, 1)];
113 113 line.center = _slider.center;
... ... @@ -144,6 +144,8 @@
144 144 // Dispose of any resources that can be recreated.
145 145 }
146 146  
  147 +#pragma mark - UITableViewDelegate & UITableViewDataSource
  148 +
147 149 - (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
148 150 return self.data.count;
149 151 }
... ...
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageContentButton.h
... ... @@ -12,7 +12,7 @@
12 12  
13 13 @interface CNLiveMessageContentButton : UIButton
14 14  
15   -@property (nonatomic, weak) UILabel *content;
  15 +@property (nonatomic, strong) UILabel *content;
16 16  
17 17 @property (nonatomic, strong) CNLiveMessageFrame *messageFrame;
18 18  
... ...
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageContentButton.m
... ... @@ -18,27 +18,28 @@
18 18 - (id)initWithFrame:(CGRect)frame {
19 19 self = [super initWithFrame:frame];
20 20 if (self) {
21   - [self createTextView];
  21 + [self addSubview:self.content];
22 22 }
23 23 return self;
24 24 }
25 25  
26 26 #pragma mark -文本视图
27   -- (void)createTextView{
28   - UILabel *content = [[UILabel alloc] init];
29   - content.userInteractionEnabled = NO;
30   - content.backgroundColor = [UIColor clearColor];
31   - content.numberOfLines = 0;
32   - content.lineBreakMode = NSLineBreakByWordWrapping;
33   - content.font = UIFontCNMake(15);
34   - [self addSubview:content];
35   - self.content = content;
  27 +- (UILabel *)content{
  28 + if(!_content){
  29 + _content = [[UILabel alloc] init];
  30 + _content.userInteractionEnabled = NO;
  31 + _content.backgroundColor = [UIColor clearColor];
  32 + _content.numberOfLines = 0;
  33 + _content.lineBreakMode = NSLineBreakByWordWrapping;
  34 + _content.font = UIFontCNMake(15);
  35 + }
  36 + return _content;
36 37 }
37 38  
38 39 - (void)setMessageFrame:(CNLiveMessageFrame *)messageFrame {
39 40 _messageFrame = messageFrame;
40 41 self.frame = messageFrame.contentFrame;
41   - [self layoutSubviews];
  42 +
42 43 //背景气泡图
43 44 UIImage *normal;
44 45 CNLiveMessageModel *message = messageFrame.message;
... ... @@ -58,11 +59,11 @@
58 59 if ([message.fromMe isEqualToString:@"1"]){
59 60 // 是我的消息
60 61 self.content.textColor = [UIColor whiteColor];
61   - self.content.frame = CGRectMake(10, 15, self.frame.size.width-20, self.frame.size.height-30);
  62 + self.content.frame = CGRectMake(ChatContentRight, ChatContentTop, self.frame.size.width-ChatContentLeft-ChatContentRight, self.frame.size.height-2*ChatContentTop);
62 63 }
63 64 else {
64 65 // 不是我的消息
65   - self.content.frame = CGRectMake(15, 15, self.frame.size.width-15, self.frame.size.height-30);
  66 + self.content.frame = CGRectMake(ChatContentLeft, ChatContentTop, self.frame.size.width-ChatContentLeft-ChatContentRight, self.frame.size.height-2*ChatContentTop);
66 67  
67 68 }
68 69  
... ... @@ -70,9 +71,6 @@
70 71 self.content.text = message.content;
71 72 self.content.font = UIFontCNMake(15);
72 73  
73   -// self.backgroundColor = [UIColor redColor];
74   -// self.textView.backgroundColor = [UIColor yellowColor];
75   -
76 74 }
77 75  
78 76 - (BOOL)canBecomeFirstResponder{
... ...
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageFrame.h
... ... @@ -9,7 +9,7 @@
9 9 #define ChatIconWH 45 //头像宽高height、width
10 10  
11 11 #define ChatContentTop 15 //文本内容与按钮上边缘间隔
12   -#define ChatContentLeft 10 //文本内容与按钮左边缘间隔
  12 +#define ChatContentLeft 20 //文本内容与按钮左边缘间隔
13 13 #define ChatContentBottom 15 //文本内容与按钮下边缘间隔
14 14 #define ChatContentRight 10 //文本内容与按钮右边缘间隔
15 15  
... ...
CNLiveSettingModule/Classes/FontSIze/CNLiveMessageFrame.m
... ... @@ -23,6 +23,7 @@
23 23 CGFloat iconY = ChatContentTop;//头像坐标Y
24 24 _iconFrame = CGRectMake(iconX, iconY, ChatIconWH, ChatIconWH);
25 25  
  26 +
26 27 // 2.计算内容位置
27 28 CGFloat contentX = ChatIconWH+ChatMargin*2;
28 29 CGFloat contentY = iconY;
... ... @@ -31,7 +32,7 @@
31 32 CGSize contentSize = [_message.content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:UIFontCNMake(15)} context:nil].size;
32 33  
33 34 if ([_message.fromMe isEqualToString:@"1"]){
34   - contentX = iconX - contentSize.width - ChatContentLeft - ChatContentRight-ChatMargin;
  35 + contentX = iconX - contentSize.width - ChatContentLeft - ChatContentRight - ChatMargin;
35 36 }
36 37 CGFloat h = 0;
37 38 if (contentSize.height + ChatContentTop + ChatContentBottom < ChatIconWH*RATIO) {
... ... @@ -39,7 +40,8 @@
39 40 }else{
40 41 h = contentSize.height + ChatContentTop + ChatContentBottom;
41 42 }
42   - _contentFrame = CGRectMake(contentX, contentY, contentSize.width + 5 + ChatContentLeft + ChatContentRight, h);
  43 +
  44 + _contentFrame = CGRectMake(contentX, contentY, contentSize.width + ChatContentLeft + ChatContentRight, h);
43 45  
44 46 _cellHeight = MAX(CGRectGetMaxY(self.contentFrame), CGRectGetMaxY(self.iconFrame));
45 47  
... ...