I am trying to create a strikethrough effect on part of a UILabel text, so fat without success. I have noticed that I can create this effect on ALL the text, but not just part of it. Here's what I have
let text = "\(20.4$) \(On Rush Hour)"
let attrStr = NSMutableAttributedString(string: text)
let range = (text as NSString).range(of: "20.4$")
attrStr.addAttribute(NSStrikethroughStyleAttributeName,
value: NSUnderlineStyle.styleSingle.rawValue,
range: range)
self.originalPriceLabel.attributedText = attrStr
Now, if I only replace
let range = (text as NSString).range(of: "20.4$")
with
let range = (text as NSString).range(of: text)
I see the strikethrough. What am I doing wrong?
Thanks!