Cannot remove border of UITextField dynamically

匿名 (未验证) 提交于 2019-12-03 03:10:03

问题:

I want to remove the border of UITextField dynamically.

I tried [stringTextField setBorderStyle:UITextBorderStyleNone];

but nothing happened. Any idea?

回答1:

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.



回答2:

Try this ones.

textField.borderStyle = UITextBorderStyleRoundedRect; textField.borderStyle = UITextBorderStyleNone; 


回答3:

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]; 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!