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
开发者_JAVA百科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.
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.
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;
精彩评论