UILabel * contentLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, KMainScreenWidth-20, 0)];
contentLabel.text = self.content;
contentLabel.numberOfLines = 0;
contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
contentLabel.font = [UIFont systemFontOfSize:25];
CGSize labelSize = [contentLabel sizeThatFits:CGSizeMake(KMainScreenWidth-20, 2000)];
contentLabel.frame = CGRectMake(10, 10, labelSize.width, labelSize.height);
[self.view addSubview:contentLabel];
contentLabel.text = self.content;
contentLabel.numberOfLines = 0;
contentLabel.lineBreakMode = NSLineBreakByWordWrapping;
contentLabel.font = [UIFont systemFontOfSize:25];
CGSize labelSize = [contentLabel sizeThatFits:CGSizeMake(KMainScreenWidth-20, 2000)];
contentLabel.frame = CGRectMake(10, 10, labelSize.width, labelSize.height);
[self.view addSubview:contentLabel];
在UITableView中显示,高度也要自适应
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 100;
本文介绍如何使用UILabel在UITableView中实现文本内容的高度自适应,并通过设置字体大小、换行模式等属性确保文本完整显示。
2528

被折叠的 条评论
为什么被折叠?



