Snail—UI学习之UITextField
来源:互联网 发布:在淘宝开店怎么取消 编辑:程序博客网 时间:2024/05/22 05:05
简单看一下UITextField的属性
- (void)createTextField{ UITextField * textField = [[UITextField alloc] initWithFrame:CGRectMake(40, 40, 240, 40)]; //设置UITextField的边框风格,否则看不见textField 盲点的话可以点到它 /* UITextBorderStyleRoundedRect 圆角 UITextBorderStyleBezel 上、左有边框 UITextBorderStyleLine 边框就是一个矩形框 背景还是父视图的背景色 UITextBorderStyleNone 默认的没有边框 */ textField.borderStyle = UITextBorderStyleRoundedRect; //设置占位符 也可以叫提示语句 textField.placeholder = @"请输入:"; //textfield 最后面的一个删除按钮显示模式 /* UITextFieldViewModeAlways 开始没有 输入后就一直显示 UITextFieldViewModeNever 什么时候也不会显示 UITextFieldViewModeUnlessEditing UITextFieldViewModeWhileEditing 输入时显示 */ textField.clearButtonMode = UITextFieldViewModeAlways; //设置键盘的风格(数字键盘、26字母键盘等等) UIKeyboardTypeNumberPad数字键盘 textField.keyboardType = UIKeyboardTypeNumberPad; //设置return的样式 即键盘上右下角的按键 textField.returnKeyType = UIReturnKeyDone; //设置textfield的默认文本文字 textField.text = @"Snail"; //当编辑完后 再一次编辑时 是否清空里面的内容 YES:清空 textField.clearsOnBeginEditing = YES; //判断textfield是否正在编辑 BOOL ret = textField.editing; //textfield是否可以被编辑 YES:可编辑 textField.enabled = NO; //输入的文本是否隐藏(password) textField.secureTextEntry = YES; //设置textfield的leftView、rightView x、y的值不会影响leftView的位置 只与width、height有关 UIView * leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 40)]; leftView.backgroundColor = [UIColor redColor]; textField.leftView = leftView; //mode必须设置 否则将不会显示在textField上面 textField.leftViewMode = UITextFieldViewModeAlways; [self.view addSubview:textField];}
效果图如下
0 0
- Snail—UI学习之UITextField
- Snail—UI学习之初识
- Snail—UI学习之UILabel
- Snail—UI学习之UIButton
- Snail—UI学习之动画Animations
- Snail—UI学习之进度条UIProgressView
- Snail—UI学习之UISegmentControl
- Snail—UI学习之开关UISwith
- Snail—UI学习之工具栏UIToolBar
- Snail—UI学习之UITableView之分组显示
- Snail—UI学习之UITableView之自定义UITableViewCell
- Snail—UI学习之得到某组件的方法
- Snail—UI学习之UIImage及UIImageView
- Snail—UI学习之自定义通知NSNotification
- Snail—UI学习之导航视图控制器UINavigationController(系统)
- Snail—UI学习之自定义导航栏NSNavigationController
- Snail—UI学习之代理传值Delegate
- Snail—UI学习之滑块UISlider
- Should I normalize/standardize/rescale the data
- Codeforces Round #313 (Div. 2)D
- 15/7/23/文件输入输出/DOM/SAX
- Python Split函数的用法总结
- curl学习(实例不断总结)
- Snail—UI学习之UITextField
- 入行时的面试题(大家不要笑哦)
- iOS前期OC训练OC_06数组
- 软件工程师面试题
- Android 自定义对话框
- OC学习笔记之分类
- NGUI研究——NGUI Scroll View
- matlab7安装后的常见问题
- 转 :C++输入的常见命令