【问题标题】:NSString with lines through each letter [duplicate]NSString,每个字母都有线条[重复]
【发布时间】:2014-04-19 16:37:23
【问题描述】:

如何编写如下字符串:

H̶̶o̶w̶̶t̶̶o̶̶w̶r̶i̶t̶̶e̶̶t̶h̶̶i̶s̶̶t̶e̶x̶̶t̶

在我的应用中,我需要显示已被新价格替换的产品的过去价格。像这样:

$̶8̶̶0̶̶0̶ -> $600

【问题讨论】:

  • 寻找NSAttributedString & NSStrikethroughStyleAttributeName
  • @Larme 你能告诉我更多关于这个,或者你能告诉我这种角色的名字吗?多搜索对我有好处。 Tks
  • @VũTuấnAnh UTF8 中有删除线字符。您可以直接在 Obj-C 字符串中使用它们。例如。 @"8̶0̶0̶"。见en.wikipedia.org/wiki/Strikethrough#Unicode

标签: string cocoa-touch cocoa nsstring strikethrough


【解决方案1】:

要获得此结果,您应该使用 NSAttributedString 并设置属性名称 NSStrikethroughStyleAttributeName。用作此键对象的数字定义了文本上线条的样式。

self.myLabel.attributedText = [[NSAttributedString alloc] initWithString:@"800" attributes:@{NSStrikethroughStyleAttributeName: @1}];

干杯

【讨论】:

  • 看起来很简单,但我的英语不好。这种字符是“删除线”。谢谢你的帮助
猜你喜欢
  • 2020-05-28
  • 2015-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-05
  • 1970-01-01
  • 1970-01-01
  • 2017-07-28
相关资源
最近更新 更多