如何编写如下字符串:
H̶̶o̶̶w̶ ̶t̶̶o̶ ̶w̶̶r̶̶i̶̶t̶̶e̶ ̶t̶̶h̶̶i̶̶s̶ ̶t̶̶e̶̶x̶̶t̶
在我的应用中,我需要显示已被新价格取代的产品的过去价格。就像这样:
$̶8̶̶0̶̶0̶ -> $600
最佳答案
要获得此结果,您应该使用 NSAttributedString 并设置属性名称 NSStrikethroughStyleAttributeName。用作此键对象的数字定义文本上线条的样式。
self.myLabel.attributedText = [[NSAttributedString alloc] initWithString:@"800" attributes:@{NSStrikethroughStyleAttributeName: @1}];
干杯
关于string - NSString 每个字母都有线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23172636/