我正在使用一个标签,该标签显示具有删除线属性的产品的旧价格.我试图为属性字符串设置删除线属性,但无法获得实际结果.
let price = 1000.0
let currencyFormatter = NumberFormatter()
currencyFormatter.numberStyle = .currency
currencyFormatter.currencyCode = "INR"
let priceInINR = currencyFormatter.string(from: price as NSNumber)
let attributedString = NSMutableAttributedString(string: priceInINR!)
attributedString.addAttribute(NSStrikethroughStyleAttributeName, value: 1, range: NSMakeRange(0, attributedString.length))
self.oldPriceLabel.attributedText = attributedString
Run Code Online (Sandbox Code Playgroud)
有没有办法同时为字符串设置货币格式化程序和删除线属性?