swift控件之旅之UITextField
发布时间:2020-12-14 01:32:04 所属栏目:百科 来源:网络整理
导读:代码如下: func UI_TextField() { ///---设置位置 var cgr = CGRect(x:10,y:20,width: 200,height: 30); ///--实例化对象的位置 var textField = UITextField(frame:cgr); ///---设置圆角形状 textField.borderStyle = UITextBorderStyle.RoundedRect; ///-
|
代码如下: func UI_TextField()
{
///---设置位置
var cgr = CGRect(x:10,y:20,width: 200,height: 30);
///--实例化对象的位置
var textField = UITextField(frame:cgr);
///---设置圆角形状
textField.borderStyle = UITextBorderStyle.RoundedRect;
///---设置文本样式
textField.placeholder = "请输入用户名";
///---设置默认值
textField.text = "we love swift 2.1";
///---设置自动调整大小,使得所有文字都能显示
textField.adjustsFontSizeToFitWidth = true;
///---设置使用的字号的最小值
textField.minimumFontSize = 15;
///---设置文字对齐方式
textField.textAlignment = NSTextAlignment.Center;
///---设置键盘样式
textField.returnKeyType = UIReturnKeyType.Go;
///---设置清除按钮
textField.clearButtonMode = UITextFieldViewMode.Always;
self.view.addSubview(textField);
} 其中,设置键盘模式时, 可以选择的样式是多种的。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
