In iOS, how do you insert images into a string with text (in a UITextView)?

How to create a UITextView that can have inline images? I looked at NSAttributedString, but iOS doesn't seem to support image attachments. Any ideas for an editable text view that can display images (I suppose RTF will do this)?

Thanks in advance for your help!

+4
source share
2 answers

The only method I know of is using a UIWebView . Unable to add images to UITextView , unfortunately, just text.

+4
source

You can use the NSTextAttachment class. It allows you to insert images into a line of text.

I found an example of this in a cool project here: https://github.com/dzog/ImgGlyph . ImgGlyph provides implementations of the UITextView and UILabel subclass that help you replace certain strings with images and ensure that they are sized correctly relative to the text surrounding it.

0
source

Source: https://habr.com/ru/post/1369351/


All Articles