問題:在iOS8.1上(8.4不存在,估計蘋果已修復),NSMutableAttributedString(NSAttributedString也一樣),如果有2段string,第二段使用刪除線效果(NSUnderlineStyleSingle)會無效。
解決方法:第一段string設置NSStrikethroughStyleAttributeName爲NSUnderlineStyleSingle
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"test "
attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleNone)}]];
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"s"
attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
NSBackgroundColorAttributeName: [UIColor clearColor]}]];
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"tring"]];