我在保留属性 NSMutableString 时遇到问题。我有一个 UITableView,每个 UITableViewCell 都有一个属性文本。设置属性文本是没有问题的,但是在选择时,UITableViewCell 的属性会丢失。这是我在cellForRowAtIndexPath中设置属性的代码:
NSMutableAttributedString *changesStyleString_h = [[NSMutableAttributedString alloc] initWithString:@"Attributes change!" attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:20], NSForegroundColorAttributeName:[UIColor yellowColor]}];
[changesStyleString_h addAttributes:@{ NSUnderlineStyleAttributeName:@(1)} range:NSMakeRange(11, 6)];
cell.mainLabel.attributedText = changesStyleString
我可以指出mainLabel也是一个 UILabel,那里没有自定义。任何正确方向的帮助将不胜感激!