如何为文本视图中的选定文本提供背景颜色 [英] how to give background color for selected text in text view

查看:92
本文介绍了如何为文本视图中的选定文本提供背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在文本视图中为所选文本指定背景颜色?

How can I give a background color for selected text in text view?

我正在开发基于文本视图的应用程序,我必须更改所选文本的颜色。

I'm developing text view based app and I have to change the color for selected text.

我尝试使用委托方法,但我没有找到这样的任何属性。你能否提出一个解决这个问题的方法?

I tried using delegate methods but I haven't found any property like this. Can you please suggest a way to overcome this issue?

推荐答案

通过使用自己的逻辑来解决问题。

Resolved issue by using own logic like.

使用


  • (void)touchesBegan :( NSSet *)触及withEvent:(UIEvent * )事件

  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

(void)touchesEnded:(NSSet *)触及withEvent:(UIEvent *)事件

(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

计算我希望添加文本颜色的框架区域以及点击完成时创建自定义视图并在其上绘制文本,并选择不同颜色的tetx范围和保持正常。它继续......我维护XML文件中的所有值来读取/编辑数据。

Calculated the Area of framing which i want to add color of text and on tapping on done creating a custom view and drawing text on it with selected range of tetx in different color and remaining normally. and it is go on... I am maintaining all values in XML file to read/edit the data.

当我们要编辑文本数据时删除自定义视图当我们辞退textView时,使用XML文件中的exisitng值添加自定义视图。按照惯例预期。

When we want to edit the text data removing the custom view and when we resign the textView adding custom view with exisitng values from XML file. Its Works as usual expected.

感谢您的支持,以解决此问题。

Thanks for all your support to resolve the issue.

这篇关于如何为文本视图中的选定文本提供背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆