Closed OnVo closed 7 years ago
我用的是UILabel 因为要用到行边距 所以用富文本添加了行边距 让后用autoHeightRatio(0) 进行高度自适应 最后显示出来的高度是没有行边距的高度
代码如下(我用的是自带的UITableViewCell cell.textLabel): cell.textLabel.textColor = [UIColor colorWithHexString:@"7d7d7d"]; cell.textLabel.numberOfLines = 0; cell.textLabel.font = [UIFont systemFontOfSize:14]; cell.textLabel.text = [NSString stringWithFormat:@"%@\n%@\n%@", @"1.工作日15:00前提现,24小时内到账;", @"2.工作日15:00后提现,下个工作日12:00前到账;", @"3.非工作日提现请求,顺延到下个工作日提现到账"];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:cell.textLabel.text]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; [paragraphStyle setLineSpacing:6]; [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [attributedString length])]; cell.textLabel.attributedText = attributedString; cell.textLabel.sd_layout .topSpaceToView(cell.contentView, 15) .autoHeightRatio(0);
富文本设置下label的isAttributedContent为YES
我用的是UILabel 因为要用到行边距 所以用富文本添加了行边距 让后用autoHeightRatio(0) 进行高度自适应 最后显示出来的高度是没有行边距的高度
代码如下(我用的是自带的UITableViewCell cell.textLabel): cell.textLabel.textColor = [UIColor colorWithHexString:@"7d7d7d"]; cell.textLabel.numberOfLines = 0; cell.textLabel.font = [UIFont systemFontOfSize:14]; cell.textLabel.text = [NSString stringWithFormat:@"%@\n%@\n%@", @"1.工作日15:00前提现,24小时内到账;", @"2.工作日15:00后提现,下个工作日12:00前到账;", @"3.非工作日提现请求,顺延到下个工作日提现到账"];