NSStrikethroughStyleAttributeName,如何在iOS 10.3中删除字符串?

Kis*_*mar 7 xcode objective-c nsmutablestring ios

我在iOS 10.3发布之前使用过这行代码,并且工作正常.

NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@\n%@",strMRP,strOffer]];

[attributeString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:12] range:NSMakeRange(0, strMRP.length)];

[attributeString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:15] range:NSMakeRange(strMRP.length, strOffer.length+1)];

[attributeString addAttribute:NSStrikethroughStyleAttributeName
                        value:[NSNumber numberWithInteger: NSUnderlineStyleDouble]
                        range:NSMakeRange(0,strMRP.length)];
Run Code Online (Sandbox Code Playgroud)

但是现在它停止了工作,有没有其他方法来进行击球?

Anb*_*hik 8

它是在IOS 10.3的bug,NSStrikethroughStyleAttributeName(任何NSUnderlineStyle情况下)未在iOS SDK 10.3更多的工作.

如果有人发现与此相关的更新答案,请通知此处,我会更新我的答案.

产品版本:10.3

创建时间:2017年3月14日

起源:2017年3月14日

Open Radar Link:http://www.openradar.appspot.com/31034683

雷达状态是当前打开状态

你可以在这里看到替代样本可能有用.


Ant*_*nko 5

我在开发者论坛上找到了一个解决方法,对我有用.添加NSBaselineOffsetAttributeName到字符串属性修复了这个问题:)