Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot remove border of UITextField dynamically

I want to remove the border of UITextField dynamically.

I tried [stringTextField setBorderStyle:UITextBorderStyleNone];

but nothing happened. Any idea?

like image 403
Burak Avatar asked Dec 26 '22 22:12

Burak


2 Answers

Is the TextField already displayed in the view when this happens? If so, you (probably) need to execute the following:

[stringTextField setBorderStyle:UITextBorderStyleNone];
[stringTextField setNeedsDisplay];

in order for the view to redraw the TextField, sans border. Note that there's no guarantee the system will immediately redraw the textField. You're indicating to the system that you'd like the field to be redrawn.

like image 193
Matt S. Avatar answered Jan 16 '23 23:01

Matt S.


With an existing UITextField I found that this worked:

[textField setEnabled:NO];
[textField setBorderStyle:UITextBorderStyleNone];

while this did not (the border remained in the view):

[textField setBorderStyle:UITextBorderStyleNone];
[textField setEnabled:NO];
like image 23
T.J. Avatar answered Jan 16 '23 22:01

T.J.