NSString *priceStr = [NSString stringWithFormat:@"%.2f元",payInfo.originalPrice];
1、原来添加中划线方式(在iOS10.3系统后失效)
// NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
// NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:priceStr attributes:attribtDic];
2、解决办法
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc] initWithString:priceStr];
[attribtStr setAttributes:@{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle], NSBaselineOffsetAttributeName : @(NSUnderlineStyleSingle)} range:NSMakeRange(0, priceStr.length)];
网友评论