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.

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