UITextField
allows you to override -caretRectForPosition:
in subclasses. I want the caret to cover the text field's entire height.
- (CGRect)caretRectForPosition:(UITextPosition *)position
{
CGRect inherited = [super caretRectForPosition:position];
inherited.origin.y = -50.0;
inherited.size.height = 200.0;
return inherited;
}
If I make it too large however (like in the example), it will stop moving around with the magnifying glass, effectively making the user unable to switch to another part of the text.
Why is that and how can I address the problem?
I figured this was only an issue when trying to make the caret way larger than the text field was. Making it cover the only entire editing rect worked fine.
Bonus: In case you're trying to get the selection range view to be the same height, take a look at
-selectionRectsForRange:
and adjust the size of all rects accordingly. You will need to subclassUITextSelectionRect
to make it mutable though.