2016-07-20 7 views
-2

私はNSAttributedStringテキストを使用し、UItextviewにGIF画像用UItextviewにNSAttributedStringテキストと画像GIF(自動再生)を挿入するには?

mycode以下dostn'tの仕事を表示するには添付ファイルの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

あなたがそれを達成しようとしていますか?この[link](http://stackoverflow.com/help/how-to-ask)をチェックして、stackoverflowで質問する方法を理解してください –

+0

stackoverflowを使うまず、素人を許してください何が間違っているのでしょうか。 –

+0

プレイメッセージとGIF画像をUITextviewで自動的に表示したいです。 –

答えて

-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]; 
[email protected]"Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah...Blah..."; 
+0

イメージはテキスト上に表示され、テキストとインラインではありません。 –

+0

原則を適用するにはNSTextAttachmentを挿入することができますアニメーション画像とテキスト内のテキストをUITextviewに入れます Iext + Gif + Text .....静的画像+テキスト... blash ..... –

+0

これと同じYYText https:// github .com/ibireme/YYText、 しかし、私はUITextViewのswiftを使いたいです。 –

関連する問題