我使用NSAttributedString文本,并希望附件gif图像显示在UItextview
中
在mycode dostn下面为gif图像工作
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
请帮助解决附件gif图片 它会自动播放。 提前致谢
答案 0 :(得分:-1)
嗨请试试这个:
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...";