I want to highlight a uitextfield when a user is editing it, so I set my textfield's borderstyle default to UITextBorderStyleNone and use the uitextfields delegates as following:
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[textField setBorderStyle:UITextBorderStyleBezel];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[textField setBorderStyle:UITextBorderStyleNone];
}
The Bezel style gets set and rendered, but when the endediting is called, the none style is not applied. I tried changing the none to another (say rounded rect), but that one does render properly.
Does anybody know how I can get this to work?
Yes, it is a bug. Anyway, I've solved by using this code:
textField.borderStyle = UITextBorderStyleLine;
textField.borderStyle = UITextBorderStyleNone;
This isn't a very beautiful method, but it does the work until Apple fixes this issue.
I had this issue also. From my testing it looked as if I could set it to any style other than UITextBorderStyleNone
.
A workaround that worked for me at least was disabling and re-enabling the textfield as seen below:
- (void)textFieldDidEndEditing:(UITextField *)textField {
textField.enabled = NO;
textField.borderStyle = UITextBorderStyleNone;
textField.enabled = YES;
}
I don't really like it but it works for now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With