Ios 为attributedString属性指定值后的布局UILabel
我有一个函数,它返回Ios 为attributedString属性指定值后的布局UILabel,ios,swift,Ios,Swift,我有一个函数,它返回NSMutableAttributedString以在UITableViewCell中设置UILabel的样式 为了解决这个问题,我在主线程中运行该代码,如下所示 DispatchQueue.main.async { self.titleLabel.attributedText = UITableViewCell.timelineTitle(prefix: "#Meeting: ", title: title, prefixColor: UIColor(hex: "
NSMutableAttributedString
以在UITableViewCell
中设置UILabel
的样式
为了解决这个问题,我在主线程中运行该代码,如下所示
DispatchQueue.main.async {
self.titleLabel.attributedText = UITableViewCell.timelineTitle(prefix: "#Meeting: ", title: title, prefixColor: UIColor(hex: "#FF3B71"))
}
但现在,标题标签开始获得更大的空间。看起来单元格没有重新计算单元格布局
label.sizeToFit()
无法解决此问题 您在哪里调用这部分代码?@mbabaev在调用处的行的单元格时配置单元格不确定,但您可以尝试在tableViewWillDisplayCell内设置attributedString…您在哪里调用这部分代码?@mbabaev在调用处的行的单元格时配置单元格不确定,但您可以尝试在tableViewWillDisplayCell内设置AttributeString。。。。