简体   繁体   English

如何将UI对象(图像)添加到UITextView或UITextField?

[英]How to add UI Objects (Image) to a UITextView or UITextField?

I would like to achieve something like the following for a UITextField or a UITextView . 我想为UITextFieldUITextView实现类似以下的功能。 The Object added to will be treated like a string when we delete texts. 当我们删除文本时,添加到的对象将被视为字符串。

I know I can add a backgrand image and get it done with too many codes. 我知道我可以添加背景图片并通过太多代码来完成。

Please let me know the best possible way to achieve this and kindly give me some pointers. 请让我知道实现此目标的最佳方法,并给我一些提示。

在此处输入图片说明

I would recommend you use Text Kit. 我建议您使用文本工具包。 Using a UITextView with Text Kit allows you to define exclusion paths (which could be used to form text around subviews) or to add attachments into the text directly. 结合使用UITextView和Text Kit,可以定义排除路径(可用于在子视图周围形成文本)或将附件直接添加到文本中。

Here's another answer that gives some pretty good direction: How to wrap text around attachments using iOS7 Text Kit? 这是另一个给出很好指导的答案: 如何使用iOS7文本工具包在附件周围包裹文本?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM