标签:bounds 安利 erp ble port ike text imp 键盘
知识点
1.基础操作
2.代理协议
#import "RootViewController.h" // 第一个条件签订协议, 好比是我要卖安利的产品,我首先要签订一个协议 @interface RootViewController ()<UITableViewDelegate> @end @implementation RootViewController - (void)viewDidLoad { [super viewDidLoad]; UITextField* field=[[UITextField alloc]initWithFrame:CGRectMake(20, 100, 260, 50)]; field.backgroundColor=[UIColor greenColor]; [self.view addSubview:field]; //友情提示 field.placeholder=@"请输入密码"; field.textColor=[UIColor redColor]; field.font=[UIFont systemFontOfSize:25]; //秘?文输入 field.secureTextEntry=YES; //右侧清空小按钮 field.clearButtonMode=UITextFieldViewModeAlways; //是否允许输入 // field.enabled=NO; //键盘的类型 // field.keyboardType=UIKeyboardTypeNumberPad; //边框 // field.borderStyle=UITextBorderStyleRoundedRect; //自己加边框 field.layer.borderColor=[UIColor redColor].CGColor; field.layer.borderWidth=2; field.layer.cornerRadius=5; field.layer.masksToBounds=YES; //return 样式 field.returnKeyType=UIReturnKeyGo; //代理方法 //第二个条件 指定代理人 好比是安利公司指定我 (self) 为代理人 field.delegate = self; } -(BOOL)textFieldShouldReturn:(UITextField *)textField { NSLog(@"你点了return键"); // 把键盘回收 // [textField resignFirstResponder]; [textField endEditing:YES]; NSString* str = textField.text; if([str isEqualToString:@"123456"]){ NSLog(@"密码正确"); } return YES; } -(void)textFieldDidBeginEditing:(UITextField *)textField { NSLog(@"开始编辑"); } -(void)textFieldDidEndEditing:(UITextField *)textField { NSLog(@"结束编辑"); } @end
标签:bounds 安利 erp ble port ike text imp 键盘
原文地址:https://www.cnblogs.com/zhangqing979797/p/13303221.html