UITextview Hide cursor / Change cursor color

In my application, in a UITextview, I want to hide the cursor.

If this is not possible, I want to change the color of the cursor.

Can we do this? I am looking for it, but I get answers only on UITextfield.

Thanks.

+4
source share
3 answers

You can hide the cursor only if you have disabled the editing property set to No

+3
source

In iOS 7, you can simply set the tintColor of your text view as the same as its backgroundColor to make the cursor invisible.

textView.tintColor = textView.backgroundColor; 

or you can try:

 textView.tintColor = [UIColor clearColor]; 
+13
source

To hide the cursor, simply subclass UITextField and override -caretRectForPosition: which is implemented by UITextField to conform to the UITextInput protocol:

 - (CGRect)caretRectForPosition:(UITextPosition *)position { return CGRectZero; // ensures the cursor won't appear } 

As for changing the color or cursor, I think this is not possible without access to the private API.

EDIT: according to S. Soffes comment, color change is possible through the tintColor property, obviously.

+2
source

All Articles