美文网首页
ios10.3+ ,UILabel的属性文字中间划线不显示情况

ios10.3+ ,UILabel的属性文字中间划线不显示情况

作者: Echo126 | 来源:发表于2017-07-26 16:46 被阅读27次

ios 10.3+ 系统,NSAttributedString 里设置 文字中间划线,只要含有汉字就会不显示中间线。目测是ios10.3+系统的bug。ios11和ios10.2 就没这个问题。

修改方法:添加设置 NSBaselineOffsetAttributeName:@(NSUnderlineStyleSingle)

例如:

1.NSAttributedString  *attrStr =

[[NSAttributedString alloc]initWithString:textStr attributes:

@{NSFontAttributeName:SYS_FONT(17),

NSForegroundColorAttributeName:RSQColorFromHex(0xa3a3a3),

NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle),

NSStrikethroughColorAttributeName:RSQColorFromHex(0xa3a3a3),

NSBaselineOffsetAttributeName:@(NSUnderlineStyleSingle)

}];

相关文章

网友评论

      本文标题:ios10.3+ ,UILabel的属性文字中间划线不显示情况

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