1.設(shè)置隨機(jī)顏色
cell.backgroundColor = [UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:1];
2.通過(guò)給定"字符內(nèi)容" "字體大小" "View的寬度" 計(jì)算高度
#pragma mark- 通過(guò)內(nèi)容動(dòng)態(tài)計(jì)算高度
-(CGFloat)textHeight:(NSString *)string andFont:(UIFont *)fontSize andWith:(CGFloat)numSize{
NSString * text = string;
UIFont * font = fontSize;
CGSize size = CGSizeMake(numSize, MAXFLOAT);
NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys:font,NSFontAttributeName, nil];
size = [text boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading attributes:dic context:nil].size;
return size.height;
}