问题描述
我有这个UIScrollView里面有图像,所有图像都是30x30。我在scrollview下也有一个UITextView。我想要做的是编辑textview,写一些文本,而不是将图像拖到textview,它将在文本之后添加(如表情符号)。
I have this UIScrollView with images inside, all the images are 30x30. I also have a a UITextView under the scrollview. What I want to do is to edit the textview, write some text, than to drag the image to the textview, and it will be added after the text (like emoji).
怎么可能?
推荐答案
你可以添加 UIImageView
作为 UITextView
的子视图。
如此,创建一个带图像的imageView:
You can add the UIImageView
as a subView of UITextView
.such like, Create an imageView with image:
UIImageView *imageView = [[UIImageView alloc] initWithImage:yourImage];
[imageView setFrame:yourFrame];
[yourTextView addSubview:imageView];
这是源代码可能对您的情况有所帮助:
And This is source code might be helpful in your case:https://github.com/HansPinckaers/GrowingTextView
https://github.com/enormego/EGOTextView
https://www.cocoacontrols.com/controls/imgglyph
https://www.cocoacontrols.com/controls/secoretextview
http://ios-blog.co.uk/featured-posts/ios-5-rich-text-editing-series/
这篇关于UITextView结合了文本和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!