美文网首页2017,我们一起努力iOS DeveloperiOS进阶指南
关于iOS 10.3系统无法显示删除线的解决方法

关于iOS 10.3系统无法显示删除线的解决方法

作者: 否极泰来_L | 来源:发表于2017-04-12 10:49 被阅读124次

我们以前一般使用这个方法添加删除线。

[string addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle)range:NSMakeRange(0,length)];

但在10.3系统以后,使用这种方法加载的无法显示删除线,这是10.3系统的bug,引用资料http://stackoverflow.com/questions/43070335/nsstrikethroughstyleattributename-how-to-strike-out-the-string-in-ios-10-3

现在我们可以使用layer来画删除线,或者更换方法为:

[string addAttributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle),NSBaselineOffsetAttributeName:@(0)}range:NSMakeRange(0,length)];

相关文章

网友评论

本文标题:关于iOS 10.3系统无法显示删除线的解决方法

本文链接:https://www.haomeiwen.com/subject/ufzpattx.html