Using TextKit to put an image in a text view

Boom goes the dynamite.

NSTextAttachment *attachment = [[NSTextAttachment alloc] initWithData:nil ofType:nil];
attachment.image = [UIImage imageNamed:@"whatever"];
NSAttributedString *attributedString = [NSAttributedString attributedStringWithAttachment:attachment];
self.textView.attributedText = attributedString;

Follow me on Twitter to keep up with what I’ve learned building my personal finance tool, Stash.

Subscribe to my mailing list to learn more about technology and business.

Your email will never be shared with anyone else.

Read more posts …
Written: October 20th, 2013
Categories: ios, textkit, uitextview, uiimage, image, text, kit