Replace words in UITextView with custom view <p>I'm dealing with a tricky situation related to an editable <code>UITextView</code>. When the user writes certain words on a <code>UITextView</code> I want to replace those words with a "tag" displaying an icon, the word (or words) and another icon.</p> <p>just like this image:</p> <p><a href="https://i.stack.imgur.com/o8UA2.png" rel="nofollow"><img src="https://i.stack.imgur.com/o8UA2.png" alt="enter image description here"></a></p> <p>I'm facing several problems here:</p> <ol> <li>How to replace the target word with the view?</li> <li>How to handle text deletion on the target word? If the text is, for example "football", the view will be displayed, but if I delete one character and get "footbal" the view should disappear and the text should come back.</li> </ol> <p>Already made some tests with <a href="https://github.com/Cocoanetics/DTRichTextEditor" rel="nofollow">DTRichTextEditor</a> and was able to detect the target words to highlight them changing their attributes, but this is way different.</p>