ios 如何更改文本字段的高度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37096586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change height of text field?
提问by 4thSpace
Is there a way to change the height of a text field in IB?
有没有办法改变IB中文本字段的高度?
If not, what is the proper way to do it in code?
如果没有,在代码中执行此操作的正确方法是什么?
回答by Rashwan L
回答by Vinoth Vino
Step 1 :Click the Attribute Inspector, Select the Border Styles
which is not the rounded one.
步骤1:点击属性检查器,选择Border Styles
不是圆角的那个。
Step 2 :Now go to Size Inspectorand change the size of the TextField.
第 2 步:现在转到Size Inspector并更改TextField的大小。
Step 3 :Create an @IBOutlet
for TextField and then add below code inside the viewWillAppear()
or viewDidAppear()
.
第 3 步:@IBOutlet
为 TextField创建一个,然后在viewWillAppear()
or 中添加以下代码viewDidAppear()
。
userTextField.borderStyle = UITextBorderStyle.roundedRect
Swift 4.2
斯威夫特 4.2
userTextField.borderStyle = UITextField.BorderStyle.roundedRect
Now you'll get the cool rounded textfield.
现在您将获得酷炫的圆形文本字段。
回答by Simon McNeil
Change to square border style and then go back to rounded border and it will stay the same. This works for xCode 11.0
更改为方形边框样式,然后返回圆形边框,它将保持不变。这适用于 xCode 11.0
回答by Balvansh Heerekar
In the attribute inspectorof your textField you can select the first, second and third Border Stylesto increase the height.
在textField的属性检查器中,您可以选择第一个、第二个和第三个边框样式来增加高度。