jleibsly2002
jleibsly2002

Reputation: 87

In iOS, how do you embed images inline with text (in a UITextView)?

How can you create a UITextView that can have images inline? I looked up NSAttributedString, but it seems iOS does not support image attachments. Any ideas for an editable text view that can display images (I suppose RTF would do this)?

Thanks in advance for your help!

Upvotes: 4

Views: 1912

Answers (2)

fatuhoku
fatuhoku

Reputation: 4911

You could use the NSTextAttachment class. It lets you insert images inline of text.

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

Upvotes: 0

James
James

Reputation: 2282

The only method I am aware of is to use a UIWebView. There is no way to add images to a UITextView, unfortunately, just plain text.

Upvotes: 4

Related Questions