小编Mah*_*esh的帖子

在swift 3中为货币格式化字符串设置删除线属性文本

我正在使用一个标签,该标签显示具有删除线属性的产品的旧价格.我试图为属性字符串设置删除线属性,但无法获得实际结果.

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)

有没有办法同时为字符串设置货币格式化程序和删除线属性?

iphone nsattributedstring uilabel ios swift

6
推荐指数
2
解决办法
3853
查看次数

标签 统计

ios ×1

iphone ×1

nsattributedstring ×1

swift ×1

uilabel ×1