cell的自适应 根据cell上面的内容 动态返回cell的高度 还有利用NSMutableAttributedString 做出效果

1.自适应cell的高度

 NSString *String  = self.eventDetail.ati_info;
    CGFloat textContentHeight = ceilf([String boundingRectWithSize:CGSizeMake(SCREEN_WIDTH - 42 - 33, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:FontNeveLightWithSize(14.0)} context:nil].size.height);
    return textContentHeight +18 * 2;

String  是你获得的字符串



2.


 NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%0.0f people already signed up/Limited to %0.0f people",self.eventDetail.number_of_participants,self.eventDetail.ati_people_count]];
                    cell.peopleLabel.attributedText = [BaseFunction attributeStringWith:attributeString andAttributes:@{NSForegroundColorAttributeName:RGB(52, 101, 168)}];




你可能感兴趣的:(ios)