tadejsv
tadejsv

Reputation: 2092

Line through UITextField

I have this weird bug with UITextField, sometimes there's a line (actually more of a transparent strip) through it. Does anyone know how to get rid of it?

Here's the picture

alt text

A link to xib file: http://db.tt/7l2Bq42

A link to the code: http://db.tt/DW0mlqQ

Edit: The bug is now solved. I'm creating this view programmatically rather than with a xib file, and the bug seems to be gone. Thanks everyone for your help.

Upvotes: 2

Views: 458

Answers (2)

William Jockusch
William Jockusch

Reputation: 27295

If you get rid of the centering, does your problem go away?

You can avoid using textAlignment altogether by subclassing the UITextField and overriding the drawTextInRect: method. To compute the rectangle, use this NSString method:

- (CGSize)sizeWithFont:(UIFont *)font forWidth:(CGFloat)width lineBreakMode:(UILineBreakMode)lineBreakMode;

Upvotes: 0

It seems that you have used center property of UITextField. If you use nameInput1.center, sometimes it gives this type of error.

You can use this line instead of setting center property.

nameInput1.textAlignment = UITextAlignmentCenter;

If you still finding some problem then please let me know. I love to solve this problem.

Upvotes: 1

Related Questions