Strong84
Strong84

Reputation: 1979

How to change cursor style of UITextView?

When editing in a UITextView, I know how to change the cursor color by setting tintColor. Is there any why to change cursor to another style?

For example: a blinking fixed-width box. or a underline "_"

Upvotes: 3

Views: 1248

Answers (1)

Strong84
Strong84

Reputation: 1979

I found a solution:

1.Subclassing UITextView

2.Overwrite caretRectForPosition: method

- (CGRect)caretRectForPosition:(UITextPosition *)position
{
    CGRect myRect = [super caretRectForPosition:position];
    myRect.size.width = 5; // Modify the width of the caret
    myRect.size.height = 5; // Modify the height of the caret

    return myRect;
}

Upvotes: 4

Related Questions