|
@@ -15,9 +15,9 @@ |
|
@@ -15,9 +15,9 @@ |
15
|
#define kContentMarginButtom 6
|
15
|
#define kContentMarginButtom 6
|
16
|
#define kMarginLeft 15
|
16
|
#define kMarginLeft 15
|
17
|
#define kMarginRight 15
|
17
|
#define kMarginRight 15
|
18
|
-#define kMarginTop 9
|
|
|
19
|
-#define kMarginBottom 9
|
|
|
20
|
-#define kPandingV 5
|
18
|
+#define kMarginTop 6
|
|
|
19
|
+#define kMarginBottom 6
|
|
|
20
|
+#define kPandingV 2
|
21
|
#define kPandingH 10
|
21
|
#define kPandingH 10
|
22
|
|
22
|
|
23
|
#define kUserAvatarWidth 35
|
23
|
#define kUserAvatarWidth 35
|
|
@@ -58,7 +58,7 @@ |
|
@@ -58,7 +58,7 @@ |
58
|
CGFloat nameHeight = [msg.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
|
58
|
CGFloat nameHeight = [msg.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
|
59
|
CGFloat msgHeight = [msg.message boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserMsg} context:nil].size.height;
|
59
|
CGFloat msgHeight = [msg.message boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserMsg} context:nil].size.height;
|
60
|
|
60
|
|
61
|
- [self.bgview setFrame:CGRectMake(kMarginLeft, kContentMarginTop, width - kMarginLeft - kMarginRight, cellHeight - kContentMarginTop-kContentMarginButtom)];
|
61
|
+ [self.bgview setFrame:CGRectMake(kMarginLeft, kContentMarginTop, width - kMarginLeft - kMarginRight, cellHeight - kContentMarginTop)];
|
62
|
[self.avatarImageView setFrame:CGRectMake(-1, 0, kUserAvatarWidth, CGRectGetHeight(self.bgview.frame))];
|
62
|
[self.avatarImageView setFrame:CGRectMake(-1, 0, kUserAvatarWidth, CGRectGetHeight(self.bgview.frame))];
|
63
|
[self.nameLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, kMarginTop, CGRectGetWidth(self.bgview.frame)-kUserAvatarWidth-2*kPandingH, nameHeight)];
|
63
|
[self.nameLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, kMarginTop, CGRectGetWidth(self.bgview.frame)-kUserAvatarWidth-2*kPandingH, nameHeight)];
|
64
|
[self.msgLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, CGRectGetMaxY(self.nameLabel.frame)+kPandingV, CGRectGetWidth(self.bgview.frame)-kUserAvatarWidth-2*kPandingH, msgHeight)];
|
64
|
[self.msgLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, CGRectGetMaxY(self.nameLabel.frame)+kPandingV, CGRectGetWidth(self.bgview.frame)-kUserAvatarWidth-2*kPandingH, msgHeight)];
|
|
@@ -83,10 +83,10 @@ |
|
@@ -83,10 +83,10 @@ |
83
|
- (UIColor *)randomColor {
|
83
|
- (UIColor *)randomColor {
|
84
|
|
84
|
|
85
|
if (_randomColor == nil) {
|
85
|
if (_randomColor == nil) {
|
86
|
-// CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
|
|
|
87
|
-// CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
|
|
|
88
|
-// CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
|
|
|
89
|
-// _randomColor = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
|
86
|
+ // CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
|
|
|
87
|
+ // CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
|
|
|
88
|
+ // CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
|
|
|
89
|
+ // _randomColor = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
|
90
|
NSString *colorHexStr = [self.colorArray objectAtIndex:arc4random() % [self.colorArray count]];
|
90
|
NSString *colorHexStr = [self.colorArray objectAtIndex:arc4random() % [self.colorArray count]];
|
91
|
_randomColor = [UIColor colorWithHexString:colorHexStr];
|
91
|
_randomColor = [UIColor colorWithHexString:colorHexStr];
|
92
|
|
92
|
|
|
@@ -125,7 +125,7 @@ |
|
@@ -125,7 +125,7 @@ |
125
|
|
125
|
|
126
|
+ (CGFloat)cellHeightWithMessage:(YH_BarrageMsgModel *)msgModel
|
126
|
+ (CGFloat)cellHeightWithMessage:(YH_BarrageMsgModel *)msgModel
|
127
|
{
|
127
|
{
|
128
|
- CGFloat cellHeight = kContentMarginTop + kMarginTop + kMarginBottom + kPandingV + kContentMarginButtom;
|
128
|
+ CGFloat cellHeight = kContentMarginTop + kMarginTop + kMarginBottom + kPandingV;
|
129
|
|
129
|
|
130
|
cellHeight += [msgModel.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
|
130
|
cellHeight += [msgModel.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
|
131
|
|
131
|
|