We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
return [tableView fd_heightForCellWithIdentifier:@"TheCell" configuration:^(id cell) { TheCell *payCell = (TheCell *)cell; payCell.saveMoney.text = @"节省三百块现大洋,又节省了六百块American dollars,it's perfect,so, line feed now"; }]; cellForRowAtIndexPath 里 cell.saveMoney.text = @"节省三百块现大洋,又节省了六百块American dollars,it's perfect,so, line feed now";
通过分层看,cell中的label高度远超过使用 return UITableViewAutomaticDimension 计算的高度。实际占用的高度也是后者正确。 xib画的cell。
The text was updated successfully, but these errors were encountered:
- (CGFloat)numberOfText{ // 获取单行时候的内容的size CGSize singleSize = [self.text sizeWithAttributes:@{NSFontAttributeName:self.font}]; // 获取多行时候,文字的size CGSize textSize = [self.text boundingRectWithSize:CGSizeMake(self.frame.size.width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.font} context:nil].size; // 返回计算的行数 return ceil( textSize.height / singleSize.height); }
你可以试试不将numberOfLines=0; 将numberOfLines = label.numberOfText
Sorry, something went wrong.
你还可以创建约束是top和height为最高优先级,bottom为最低优先级。如下可完美解决你的问题
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.trailing.inset(20); make.top.inset(30).priorityHigh(); make.height.mas_greaterThanOrEqualTo(self.titleLabel.font.lineHeight).priorityHigh(); make.bottom.inset(30).priorityLow(); }];
No branches or pull requests
return [tableView fd_heightForCellWithIdentifier:@"TheCell" configuration:^(id cell) {
TheCell *payCell = (TheCell *)cell;
payCell.saveMoney.text = @"节省三百块现大洋,又节省了六百块American dollars,it's perfect,so, line feed now";
}];
cellForRowAtIndexPath 里
cell.saveMoney.text = @"节省三百块现大洋,又节省了六百块American dollars,it's perfect,so, line feed now";
通过分层看,cell中的label高度远超过使用 return UITableViewAutomaticDimension 计算的高度。实际占用的高度也是后者正确。 xib画的cell。
The text was updated successfully, but these errors were encountered: