标签:cell的frame
{
_message = message;
//屏幕的宽度
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
//间隙
CGFloat padding = 10;
//时间
CGFloat timeX = 0;
CGFloat timeY = 0;
CGFloat timeW = screenWidth;
CGFloat timeH = 30;
_timeF = CGRectMake(timeX, timeY, timeW, timeH);
//2.头像
CGFloat iconH = 30;
CGFloat iconW = 30;
CGFloat iconY = CGRectGetMaxY(_timeF) + padding;
CGFloat iconX = 0;
if (GYLMessageModelTypeMe == _message.type) {//自己发的
//x = 屏幕宽度 - 间隙 - 头像宽度
iconX = screenWidth - padding - iconW;
}else iconX = padding;
_iconF = CGRectMake(iconX, iconY, iconW, iconH);
//3.正文
NSDictionary * dict = @{NSFontAttributeName :GYLTextFont};
CGSize maxSize = CGSizeMake(200, MAXFLOAT);
CGSize textSize = [_message.text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size;
CGFloat textW = textSize.width;
CGFloat textH = textSize.height;
CGFloat textY = iconY;
CGFloat textX = 0;
if (GYLMessageModelTypeMe == _message.type) {//自己发的
// x = 头像x - 间隙 - 文本的宽度
textX = iconX - padding - textW;
}else
{
//头像的最大的x+ 间隙
textX = CGRectGetMidX(_iconF) + padding;
}
_textF = CGRectMake(textX, textY, textW, textH);
// 4.行高
CGFloat maxIconY = CGRectGetMaxY(_iconF);
CGFloat maxTextY = CGRectGetMaxY(_textF);
// _cellHeight = (maxIconY > maxTextY? (maxIconY + padding) : (maxIconY + padding));
_cellHeight = MAX(maxIconY, maxTextY) + padding;
}
标签:cell的frame
原文地址:http://blog.csdn.net/guoyule2010/article/details/43997129