I have a textview which contains multiple paragraphs. Each string can be formatted differently, for example some strings are bold and others using italicized fonts.
How would I get the attributes for a specific substring and get the attributes for the substring before that one?
For example I want to get the attributes for the selected text as well as the text that is displayed before it.
Here is what I have so far.
let range: UITextRange = textView.selectedTextRange!
let selectedText = textTV.text(in: range)
let previousRange: UITextRange = textView.textRange(from: textView.beginningOfDocument, to: range.start)!
let previousText = textTV.text(in: previousRange)
With this I was able to get the string that was selected by the user. As well as the text behind it.
However I don't know how to rip the attributes of that string out.