[英]Cannot remove border of UITextField dynamically
I want to remove the border of UITextField dynamically. 我想动态删除UITextField的边框。
I tried [stringTextField setBorderStyle:UITextBorderStyleNone];
我试过
[stringTextField setBorderStyle:UITextBorderStyleNone];
but nothing happened. 但什么都没发生。 Any idea?
任何想法?
Is the TextField
already displayed in the view when this happens? 发生这种情况时,
TextField
是否已显示在视图中? 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. 为了让视图重绘
TextField
,没有边框。 Note that there's no guarantee the system will immediately redraw the textField
. 请注意,无法保证系统会立即重绘
textField
。 You're indicating to the system that you'd like the field to be redrawn. 您正在向系统指示您希望重绘该字段。
With an existing UITextField I found that this worked: 使用现有的UITextField,我发现这有效:
[textField setEnabled:NO];
[textField setBorderStyle:UITextBorderStyleNone];
while this did not (the border remained in the view): 虽然这没有(边界仍然在视图中):
[textField setBorderStyle:UITextBorderStyleNone];
[textField setEnabled:NO];
Try this ones. 试试这个。
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.borderStyle = UITextBorderStyleNone;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.