-1

I use NSAttributedString text ,and want attachment gif image to show in UItextview

below mycode dostn't work for gif image

let mytext = UITextview()
let result = NSMutableAttributedString()
let attachment = NSTextAttachment() 
attachment.image = UIImage(named:"abc.gif")
let attachmentString = NSAttributedString(attachment: attachment) 
let myString = NSMutableAttributedString(string:"")
myString.appendAttributedString(attachmentString) 
result.appendAttributedString(myString)
mytext.attrbutedText = result

Please help to resolve Attachment gif image And it will play automatically. Thanks in advance

1 Answers1

-1

Hi Please Try out this:

 UIImageView * imageview =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"download.gif"]];
 NSMutableArray *exclutionPaths = [NSMutableArray array];
[exclutionPaths addObject:[UIBezierPath bezierPathWithRect:CGRectInset(imageview.frame, -4, 0)]];
[_textView.textContainer setExclusionPaths:exclutionPaths];
[_textView addSubview:imageview]; 
_textView.text=@"Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...";
Sagar Shirbhate
  • 801
  • 7
  • 17