Authored by 郁健超

修改弹幕cell的UI review by洛克

... ... @@ -21,7 +21,7 @@
#define kPandingH 10
#define kUserAvatarWidth 35
#define kUserNameLableMaxWidth (150 * kScreenPointScale)
#define kUserNameLableMaxWidth (245 * kScreenPointScale - 85)
#define kFontUserName [UIFont fontOfLightWithSize:11]
#define kFontUserMsg [UIFont fontOfSCWithSize:13]
... ... @@ -55,13 +55,18 @@
- (void)reLayoutCellWithWidth:(CGFloat)width msg:(YH_BarrageMsgModel *)msg {
CGFloat cellHeight = [YH_BarrageMsgCell cellHeightWithMessage:msg];
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)];
[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)];
CGSize msgSize = [msg.message boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserMsg} context:nil].size;
NSString *nameLabelText = [NSString stringWithFormat:@"@%@", msg.userName];
CGSize nameSize = [nameLabelText boundingRectWithSize:CGSizeMake(kUserNameLableMaxWidth, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : kFontUserName} context:nil].size;
[self.avatarImageView setFrame:CGRectMake(-1, 0, kUserAvatarWidth, cellHeight - kContentMarginTop)];
[self.nameLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, kMarginTop, nameSize.width, nameSize.height)];
[self.msgLabel setFrame:CGRectMake(CGRectGetWidth(self.avatarImageView.frame)+kPandingH, CGRectGetMaxY(self.nameLabel.frame)+kPandingV, msgSize.width, msgSize.height)];
CGFloat bgwidth = CGRectGetMaxX(self.msgLabel.frame) + 10;
if (nameSize.width > msgSize.width) {
bgwidth = CGRectGetMaxX(self.nameLabel.frame) + 10;
}
[self.bgview setFrame:CGRectMake(kMarginLeft, kContentMarginTop, bgwidth, cellHeight - kContentMarginTop)];
}
... ...