解决 Label 富文本删除线¥100 不水平 (断层) 问题
添加删除线:
NSMutableAttributedString * discount = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"¥%@",discountStr] attributes:
@{NSFontAttributeName : [UIFont jk_systemFontOfPxSize:30],
NSForegroundColorAttributeName : JKSameRGBColor(153),
NSStrikethroughStyleAttributeName:@(NSUnderlineStyleDouble),
NSStrikethroughColorAttributeName : [UIColor yellowColor]
其中:NSStrikethroughStyleAttributeName 删除线
实际上,设置删除线 NSStrikethroughColorAttributeName 的时候,值也是这个枚举。
// NSUnderlineStyleNone 不设置下划线/删除线
// NSUnderlineStyleSingle 设置下划线/删除线为细的单线
// NSUnderlineStyleThick 设置下划线/删除线为粗的单线
// NSUnderlineStyleDouble 设置下划线/删除线为细的双线
// NSUnderlinePatternSolid 设置下划线/删除线样式为连续的实线
//NSUnderlinePatternDot 设置下划线/删除线样式为点,也就是虚线,比如这样:------
// NSUnderlinePatterDash 设置下划线/删除线样式为破折号,比如这样:—— —— ——
// NSUnderlinePatternDashDot 设置下划线/删除线样式为连续的破折号和点,比如这样:——-——-——-
// NSUnderlinePatternDashDotDot 设置下划线/删除线样式为连续的破折号、点、点,比如:——--——--——--
// NSUnderlineByWord 在有空格的地方不设置下划线/删除线
当 : ¥ 和 100 组合 时 ,删除线出现断层,不水平现象
![](https://img.haomeiwen.com/i3891550/5f52107d8840d6af.png)
当我用$符号时,发现没问题,所以我猜测是 中英文 结合问题
![](https://img.haomeiwen.com/i3891550/e00a05aef1f27457.png)
上面的是 直接 快捷键shift + 4 打得 符号,有断层
下面是 用 搜狗 打“RMB”选的符号,没有断层
![](https://img.haomeiwen.com/i3891550/be9bbb9a45fb3f0e.png)