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: 
**SWIFT CODE**

```
let attributeString: NSMutableAttributedString =  NSMutableAttributedString(string: "Your Text")
    attributeString.addAttribute(NSStrikethroughStyleAttributeName, value: 2, range: NSMakeRange(0, attributeString.length))

```

then:

```
yourLabel.attributedText = attributeString

```

Thanks to [Prince answer](https://stackoverflow.com/a/13133178/1311093) ;)
I might be late to the party. 

Anyway, I am aware about the `NSMutableAttributedString` but recently I achieved the same functionality with slightly different approach.

* I added the UIView with height = 1.
* Matched the leading and trailing constraints of the UIView with the label's leading and trailing constraints
* Aligned the UIView at centre of the Label

After following all the above steps my Label, UIView and its constraints were looking like below image.

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