Swift 中划线

image.png

方式一

let priceString = NSMutableAttributedString.init(string: "99元")
priceString.addAttribute(.strikethroughStyle, value: NSUnderlineStyle.single.rawValue, range: NSRange(location: 0, length: 2))
amountLab.attributedText = priceString

方式二

使用三方库ASAttributedString

amountLab.attributed.text = "\("99元", .strikethrough(NSUnderlineStyle.single, color: .red))"

你可能感兴趣的:(Swift 中划线)