UITextField
来源:互联网 发布:java面对对象经典案例 编辑:程序博客网 时间:2024/05/22 06:40
code
圆角,有占位符
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 190, 30)]; myTextField.borderStyle = UITextBorderStyleRoundedRect; myTextField.placeholder = @"这是占位符"; [self.view addSubview:myTextField]; [myTextField release];
按return回收键盘
-(BOOL) textFieldShouldReturn:(UITextField *) textField{ [textField resignFirstResponder]; return YES;}
防止键盘挡住文本框
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField{ CGFloat h = textField.center.y - self.view.frame.size.height / 2; if (h > 0) { self.view.center = CGPointMake(self.view.center.x, self.view.center.y - h); } return YES;}- (BOOL) textFieldShouldEndEditing:(UITextField *)textField{// self.view.frame = CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height); CGFloat h = textField.center.y - self.view.frame.size.height / 2; if (h > 0) { self.view.center = CGPointMake(self.view.center.x, self.view.center.y + h); } return YES;}
property
- borderStyle
UITextBorderStyleRoundedRect圆形边框
- layer.borderWidth
- placeholder
占位符
- secureTextEntry
密文输入
- keyboardType
键盘显示样式
- returnKeyType
return按钮样式
- clearButtonMode
一次性清除输入的内容
- inputAccessoryView
辅助视图(键盘上面的视图)
- inputView
弹出自定义视图,可以用来弹出自定义键盘
protocol
-(BOOL) textFieldShouldClear: 可实现撤销操作
-(BOOL) textFieldShouldReturn: 回收键盘
-(BOOL) textFieldShouldBeginEditing:
-(BOOL) textFieldShouldEndEditing:
-(BOOL)textField: shouldChangeCharactersInRange:replacementString
-(void) textFieldDidEndEditing:
0 0
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- 第三周项目4:穷举法解决组合问题---三色球问题
- 单向链表的创建与遍历(先进先出和先进后出)
- 第三周项目4-穷举法-年龄几何
- 第2周项目3:小试循环(5)
- 第三周项目3——输出星号图(2)空心三角
- UITextField
- Nginx隐藏端口号详解
- 正则匹配所有文本以及在windows下的使用工具
- 随记
- D. 连续最大积吗 为什么要留代码呢 因为我缝缝补补的就过了 也不知道咋回事
- httpservlet详解
- 九度题目1083特殊乘法
- 密码强度等级
- 用JAVA(Myeclipse)实现可视化日历