ios - UITextField Caret stops moving around when too large -
uitextfield
allows override -caretrectforposition:
in subclasses. want caret cover 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 make large (like in example), stop moving around magnifying glass, making user unable switch part of text.
why , how can address problem?
i figured issue when trying make caret way larger text field was. making cover entire editing rect worked fine.
- (cgrect)caretrectforposition:(uitextposition *)position { cgrect const inherited = [super caretrectforposition:position]; cgrect const rect = ({ cgrect rect = inherited; rect.origin.y = 0.0; rect.size.height = cgrectgetheight([self editingrectforbounds:self.bounds]); rect; }); return rect; }
bonus: in case you're trying selection range view same height, take @ -selectionrectsforrange:
, adjust size of rects accordingly. need subclass uitextselectionrect
make mutable though.
Comments
Post a Comment