前言:
iOS10.3升级后,发现项目中类似商城,会用到的一些原价的下划线失效了,主要原因是Label上的文字只要包含有“中文”,富文本字符串的中划线就会失效
WX20170421-161102@2x.png
解决方法:
- 让富文本支持"中文"
增加一个富文本属性:
NSBaselineOffsetAttributeName : @(NSUnderlineStyleSingle)
具体方法为:
NSMutableAttributedString *attributeMarket = [[NSMutableAttributedString alloc] initWithString:originalPriceLabel.text];
[attributeMarket setAttributes:@{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle], NSBaselineOffsetAttributeName : @(NSUnderlineStyleSingle)} range:NSMakeRange(0,originalPriceLabel.text.length)];
originalPriceLabel.attributedText = attributeMarket;