开发者

how to give background color for selected text in text view

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?


There is no way to change the selection color within AppStore limitation. In fact, considering MobileNotes.app's selection background color is also light blue despite the caret is brown, we can see that Apple doesn't intend to allow non-blue selection background color.

However, you can calculate the rectangles occupied by the selection, then make a colored transparent non-interacting UIView on top of it to simulate a change of background color.


You can change the selection color globally (within your app) by overriding the undocumented method +[UIColor selectionTintColor] (e.g. using method_setImplementation, etc.).


Resolved issue by using own logic like.

Using

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

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

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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜