UITextField
来源:互联网 发布:四川眉山广电数据机房 编辑:程序博客网 时间:2024/06/06 13:18
//创建 UITextField*textfield = [[UITextField alloc]initWithFrame:CGRectMake(20,20,200,40)]; [self.window addSubview:self.myTextField]; //设置背景颜色 self.myTextField.backgroundColor = [UIColor clearColor]; //设置输入框样式 self.myTextField.borderStyle = UITextBorderStyleRoundedRect; //密文输入 self.myTextField.secureTextEntry = YES; //设置占位提示符 self.myTextField.placeholder = @"请输入"; //设置输入框删除按钮 self.myTextField.clearButtonMode = UITextFieldViewModeAlways; //设置键盘类型 self.myTextField.keyboardType = UIKeyboardTypeNumberPad;/******按按钮键盘隐藏*********************************/ //创建按钮 UIButton *Button = [UIButton buttonWithType:UIButtonTypeCustom]; [self.window addSubview:Button]; Button.frame = CGRectMake(20, 80, 100, 30); Button.backgroundColor = [UIColor cyanColor]; [Button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];-(void) buttonAction:(UIButton *)b{ [self.myTextField resignFirstResponder]; //取消第一响应者}/******************************************************//******按return键盘隐藏*********************************/1.签UITextFieldDelegate协议@interface AppDelegate : UIResponder <UIApplicationDelegate,UITextFieldDelegate>2.成为代理人哪个输入框成为代理人哪个输入框有此功能 self.myTextField.delegate = self;3.实现协议里的方法//点击return建的时候被触发通用,一个就可以给所有输入框用- (BOOL)textFieldShouldReturn:(UITextField *)textField{ [self.myTextField resignFirstResponder]; return YES;}/******************************************************//******按空白处键盘隐藏*********************************/ //按空白处键盘回收 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(backgroundTap:)]; [self.view addGestureRecognizer:tap];//按空白处键盘回收调用的方法- (IBAction)backgroundTap:(id)sender { [self.studentDetailV.tf1 resignFirstResponder]; [self.studentDetailV.tf2 resignFirstResponder]; [self.studentDetailV.tf3 resignFirstResponder]; [self.studentDetailV.tf4 resignFirstResponder]; [self.studentDetailV.tf5 resignFirstResponder]; }/******************************************************/
0 0
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- UITextField
- 递归算法——C语言
- ADODB.Stream 错误 '800a0bbc' 写入文件失败
- linux驱动lcd2002
- VS2013源码转换VS2010的解决方法
- 1.3.3 头文件
- UITextField
- AFNetworking允许不通过证书验证访问https(AFNetworking+SSL)
- rpm制作
- css属性简介 小结
- Real-time stream processing: The next step for Apache Flink
- 教你做IOS推送 包会!
- liunx路由跟踪
- 基于udp的协议的 socket编程小例子
- 数据结构与算法面试题80道