2

I have a problem with UITextField when I wish to render characters like Å and such within its rect.

The top of it is being clipped out, Making the Å look like an A.

In some cases i have solved it with a custom UITextField like this :

- (void)drawTextInRect:(CGRect)rect {
    rect.origin.y = rect.origin.y+5;
    [super drawTextInRect:rect];
}

Which works when the text is just being displayed normally like this :

enter image description here

But when you start editing the text, its like the drawTextInRect is no longer applied, and the top of the characters disappear again.

Like so:

enter image description here

Does anyone else have ideas to how to fix this ?

Nils Munch
  • 8,805
  • 11
  • 51
  • 103
  • you can't just increase the size of the field? And from your screenshot, it doesn't look like it is correctly centered. Are you modifying the standard UITextField here? – Paul de Lange Oct 26 '12 at 12:08

1 Answers1

1

Override - (CGRect)textRectForBounds:(CGRect)bounds instead to adjust the text rect in all circumstances. I suspect that UITextField uses a label when you don't edit the text and something else when you do and that only one of them calls drawTextInRect: in particular.

Jesper
  • 7,477
  • 4
  • 40
  • 57
  • This does not seem to do the trick. The text is still in the same place, and if i use this instead of drawTextInRect, the glyphs are being cut, and I'm back to having Å appear as A. – Nils Munch Oct 26 '12 at 11:21