我有一个聊天应用程序,我需要在其中发送图像(表情符号)和文本。
现在,我可以通过NSTextAttachment
(下面的代码)添加图像
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
NSString *img=[NSString stringWithFormat:@"%@.png",imgName];
textAttachment.image =[UIImage imageNamed:img];
NSAttributedString *attrStringWithImage = [NSAttributedString attributedStringWithAttachment:textAttachment];
NSMutableAttributedString *nStr=[[NSMutableAttributedString alloc]initWithAttributedString:_txtChat.attributedText];
[nStr appendAttributedString:attrStringWithImage];
_txtChat.attributedText =nStr;
现在,我想要的是:)
在微笑图标上附加一个自定义文本说“”,以便在调用时_txtChat.text
返回:) 而不是UIImage
. 所以,如果用户看到Hii <Smilie>
,我会得到"Hii :)"
。我无法确定是否有可能获得。