Authored by 郁健超

修改弹幕cell UIreview by洛克

... ... @@ -43,8 +43,8 @@
self.nameLabel.text = [NSString stringWithFormat:@" @%@已加入 ", name];
// CGFloat nameWidth = [self.nameLabel.text boundingRectWithSize:CGSizeMake(kUserNameWidth, 20) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontName} context:nil].size.width;
// [self.nameLabel setWidth:nameWidth];
CGFloat nameWidth = [self.nameLabel.text boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, 20) options:NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName : kFontName} context:nil].size.width;
[self.nameLabel setWidth:nameWidth];
}
... ... @@ -52,7 +52,7 @@
- (UILabel *)nameLabel
{
if (_nameLabel == nil) {
_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 6, 200, 20)];
_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 6, kUserNameWidth, 20)];
[_nameLabel setFont:kFontName];
[_nameLabel setTextColor:[UIColor blackColor]];
[_nameLabel setTextAlignment:NSTextAlignmentLeft];
... ...
... ... @@ -15,9 +15,9 @@
#define kContentMarginButtom 6
#define kMarginLeft 15
#define kMarginRight 15
#define kMarginTop 9
#define kMarginBottom 9
#define kPandingV 5
#define kMarginTop 6
#define kMarginBottom 6
#define kPandingV 2
#define kPandingH 10
#define kUserAvatarWidth 35
... ... @@ -58,7 +58,7 @@
CGFloat nameHeight = [msg.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
CGFloat msgHeight = [msg.message boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserMsg} context:nil].size.height;
[self.bgview setFrame:CGRectMake(kMarginLeft, kContentMarginTop, width - kMarginLeft - kMarginRight, cellHeight - kContentMarginTop-kContentMarginButtom)];
[self.bgview setFrame:CGRectMake(kMarginLeft, kContentMarginTop, width - kMarginLeft - kMarginRight, cellHeight - kContentMarginTop)];
[self.avatarImageView setFrame:CGRectMake(-1, 0, kUserAvatarWidth, CGRectGetHeight(self.bgview.frame))];
[self.nameLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, kMarginTop, CGRectGetWidth(self.bgview.frame)-kUserAvatarWidth-2*kPandingH, nameHeight)];
[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 @@
- (UIColor *)randomColor {
if (_randomColor == nil) {
// CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
// CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
// CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
// _randomColor = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
// CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
// CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
// CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
// _randomColor = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
NSString *colorHexStr = [self.colorArray objectAtIndex:arc4random() % [self.colorArray count]];
_randomColor = [UIColor colorWithHexString:colorHexStr];
... ... @@ -125,7 +125,7 @@
+ (CGFloat)cellHeightWithMessage:(YH_BarrageMsgModel *)msgModel
{
CGFloat cellHeight = kContentMarginTop + kMarginTop + kMarginBottom + kPandingV + kContentMarginButtom;
CGFloat cellHeight = kContentMarginTop + kMarginTop + kMarginBottom + kPandingV;
cellHeight += [msgModel.userName boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size.height;
... ...