Question: I want to create a `UILabel` in which the text is like this

![enter image description here](https://i.stack.imgur.com/pTq7k.png)

How can I do this? When the text is small, the line should also be small.

Answer: 
In Swift, using the single strikethrough line style:

```swift
let attributedText = NSAttributedString(
    string: "Label Text",
    attributes: [.strikethroughStyle: NSUnderlineStyle.single.rawValue]
)
label.attributedText = attributedText

```

Additional strikethrough styles (**Remember to use the .rawValue**):

* `.none`
* `.single`
* `.thick`
* `.double`

Strikethrough patterns (to be OR-ed with the style):

* `.patternDot`
* `.patternDash`
* `.patternDashDot`
* `.patternDashDotDot`

Specify that the strikethrough should only be applied across words (not spaces):

* `.byWord`
On iOS 10.3 has an issue on rendering strikethrough line fixes by Adding a NSBaselineOffsetAttributeName, as explained here, to the attributed string brings back the strikethrough line. Overriding drawText:in: can be slow especially on Collection View or Table View Cells.

One sol - Add view to render a line.

Second sol -

```
attributeString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: 2, range: NSMakeRange(0, attributeString.length))
attributeString.addAttribute(NSAttributedString.Key.baselineOffset, value: 2, range: NSMakeRange(0, attributeString.length))```

```