0

Here is my code:

UIImage *image = [UIImage imageNamed:@"recipient.png"];
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = image;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString    alloc] initWithString:htmlString];

NSAttributedString *attstringImage = [NSAttributedString  attributedStringWithAttachment:textAttachment];

[attributedString appendAttributedString:attstringImage];

NSAttributedString *titleContent = (NSAttributedString *)attributedString;

NSDictionary *documentAttributes = @{NSDocumentTypeDocumentAttribute:   NSHTMLTextDocumentType};
NSData *htmlData = [titleContent dataFromRange:NSMakeRange(0, titleContent.length) documentAttributes:documentAttributes error:NULL];

NSString *html = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • Check this might be help you http://stackoverflow.com/questions/29152660/extract-uiimage-from-nsattributed-string – kb920 Jun 07 '16 at 09:27
  • Why duplicate? http://stackoverflow.com/questions/37605862/convert-nsattributedstring-with-nstextattachment-having-image-to-html-in-ios-o – Larme Jun 07 '16 at 11:48
  • you implement that?.I fetch same issue. – Gami Nilesh Apr 17 '17 at 08:04

0 Answers0