How to add padding to a substring UITextViewthat is NSMutableAttributedString(shown here highlighted in yellow)?

Currently, I have attribute text (image 2) without any additions around the attribute text, but you need to add some addition (image 3) to it, which represents some distance around the selected text (not all UITextView.
Here is a close-up comparing how NSMutableAttributedStringwith / without filling out (this addition should not apply to the rest of the text that is not allowed):

This is how I get the text from now UITextView(after finding the range of text I want to select and save the attributed text in attributedText):
var highlightedText = NSMutableAttributedString(string: "this text is highlighted")
let highlightedRange = NSRange(location: 0, length: highlightedText.characters.count)
highlightedText.addAttribute(NSBackgroundColorAttributeName,
value: UIColor.yellow, range: highlightedRange)
attributedText.replaceCharacters(in: highlightedRange, with: highlightedText)