uitextfield的常用属性
2015-07-24 10:05
369 查看
//文本框
UITextField *textField=[[UITextField alloc] initWithFrame:CGRectMake(50, 50, 200, 50)];
//textField.backgroundColor=[UIColor yellowColor];
//文本显示设置
//文字
textField.text=@"110";//提前输入的文字,可以删除
//文字颜色
textField.textColor=[UIColor redColor];
//文字对其位置
textField.textAlignment=NSTextAlignmentRight;
//文字大小
textField.font=[UIFont systemFontOfSize:25];
//输入提示
textField.placeholder=@"请输入";
//输入控制设置
//是否允许输入,YES允许输入,NO不允许输入,默认为YES
//textField.enabled=YES;
//是否清空(开始输入是否清空之前文字.默认NO)
textField.clearsOnBeginEditing=YES;
//密码
textField.secureTextEntry=YES;
//键盘
textField.keyboardType=UIKeyboardTypeNumberPad;//纯数字键盘
UIView *keyBoardView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
keyBoardView.backgroundColor=[UIColor redColor];
//1.取代键盘位置的view,以后可以自己定义按钮输入
//textField.inputView=keyBoardView;
//2.在原来键盘上面 ,加一块view,上部可以实现自定义按钮输入
textField.inputAccessoryView=keyBoardView;
//外观设置
//输入框形状
textField.borderStyle=UITextBorderStyleRoundedRect;
UIImageView *imV=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"2.png"]];
imV.frame=CGRectMake(0, 0, 50, 50);
//在文本框左边显示一张图片
textField.leftView=imV;
textField.leftViewMode=UITextFieldViewModeAlways;
UIImageView *imV1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]];
imV1.frame=CGRectMake(0, 0, 50, 50);
//在文本框右边显示一张图片
textField.rightView=imV1;
textField.rightViewMode=UITextFieldViewModeAlways;
//清楚文本内部文字 按钮
textField.clearButtonMode=UITextFieldViewModeAlways;
[backGroundView addSubview:textField];
UITextField *textField=[[UITextField alloc] initWithFrame:CGRectMake(50, 50, 200, 50)];
//textField.backgroundColor=[UIColor yellowColor];
//文本显示设置
//文字
textField.text=@"110";//提前输入的文字,可以删除
//文字颜色
textField.textColor=[UIColor redColor];
//文字对其位置
textField.textAlignment=NSTextAlignmentRight;
//文字大小
textField.font=[UIFont systemFontOfSize:25];
//输入提示
textField.placeholder=@"请输入";
//输入控制设置
//是否允许输入,YES允许输入,NO不允许输入,默认为YES
//textField.enabled=YES;
//是否清空(开始输入是否清空之前文字.默认NO)
textField.clearsOnBeginEditing=YES;
//密码
textField.secureTextEntry=YES;
//键盘
textField.keyboardType=UIKeyboardTypeNumberPad;//纯数字键盘
UIView *keyBoardView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
keyBoardView.backgroundColor=[UIColor redColor];
//1.取代键盘位置的view,以后可以自己定义按钮输入
//textField.inputView=keyBoardView;
//2.在原来键盘上面 ,加一块view,上部可以实现自定义按钮输入
textField.inputAccessoryView=keyBoardView;
//外观设置
//输入框形状
textField.borderStyle=UITextBorderStyleRoundedRect;
UIImageView *imV=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"2.png"]];
imV.frame=CGRectMake(0, 0, 50, 50);
//在文本框左边显示一张图片
textField.leftView=imV;
textField.leftViewMode=UITextFieldViewModeAlways;
UIImageView *imV1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]];
imV1.frame=CGRectMake(0, 0, 50, 50);
//在文本框右边显示一张图片
textField.rightView=imV1;
textField.rightViewMode=UITextFieldViewModeAlways;
//清楚文本内部文字 按钮
textField.clearButtonMode=UITextFieldViewModeAlways;
[backGroundView addSubview:textField];
相关文章推荐
- uilabel的常用属性
- android 更新界面视图 Handler和runOnUiThread
- uiview的常用属性
- UISearchBar 和 UISearchDisplayController的使用
- HDOJ 5288 OO’s Sequence 水
- HDU 5301 Building (找规律)
- hdu 5288 OO’s Sequence
- Android中build target,minSdkVersion,targetSdkVersion,maxSdkVersion概念区分
- UIActivityViewController
- UITextField详解
- 关于ViewPager、ViewFilpper、ViewFlow三种实现水平向滑动方式的比较
- HDU 5301 Buildings(2015多校第二场)
- UITableView性能优化
- UITableViewCell 分割线左对齐
- easy ui form 提交问题
- Android开发规范(编码+性能+UI)
- Assert.IsTrue();Assert.AreEqual();Assert.IsNotNull()
- String、StringBuffer与StringBuilder之间区别
- MenuItemToggle的使用
- UIProgressView和UISlider