-(void)creatTextField{
CGFloat pendding =10 ;
UITextField * text1 = [[UITextField alloc]initWithFrame:CGRectMake(pendding, 30, KScreenSize.width-2*pendding, 30)];
//设置背景
text1.backgroundColor =[UIColor clearColor];
text1.borderStyle =UITextBorderStyleLine;
//设置提示语
text1.placeholder =@"请输入用户名";
//设置字体
// text1.text =@"xxxx";
//设置水平对齐
text1.textAlignment = NSTextAlignmentCenter;
//设置垂直方向
//text1.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
//字体颜色
text1.textColor = [UIColor redColor];
//字体大小
text1.font =[UIFont systemFontOfSize:25];
//设置自适应 如果字体内容超出 范围 那么这时可以自适应
text1.adjustsFontSizeToFitWidth = YES;
//设置最小字体
text1.minimumFontSize = 15;
//textField 只能显示一行
//设置清楚按钮
text1.clearButtonMode = UITextFieldViewModeAlways;
//下次进入编辑模式的时候是否清楚之前内容;
text1.clearsOnBeginEditing = YES;
//设置键盘风格(数子键盘 电话键盘 邮箱键盘
text1.keyboardType = UIKeyboardTypeDefault;
//键盘的颜色
text1.keyboardAppearance = UIKeyboardAppearanceLight;
/**
* return 键的类型
*/
text1.returnKeyType = UIReturnKeyGo;
//设置输入的英文首字母
text1.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
//设置自动纠错
text1.autocorrectionType =UITextAutocorrectionTypeNo;
[self.view addSubview:text1];
[text1 release];
//获取一个frame y+ height的值
CGFloat y= CGRectGetMaxY(text1.frame);
NSLog(@"y:%f",y);
UITextField *text2 = [[UITextField alloc]initWithFrame:CGRectMake(pendding, y+20, KScreenSize.width-2*pendding, 30)];
text2.borderStyle =UITextBorderStyleLine;
text2.secureTextEntry = YES;
[self.view addSubview:text2];
[text2 release];
}
CGFloat pendding =10 ;
UITextField * text1 = [[UITextField alloc]initWithFrame:CGRectMake(pendding, 30, KScreenSize.width-2*pendding, 30)];
//设置背景
text1.backgroundColor =[UIColor clearColor];
text1.borderStyle =UITextBorderStyleLine;
//设置提示语
text1.placeholder =@"请输入用户名";
//设置字体
// text1.text =@"xxxx";
//设置水平对齐
text1.textAlignment = NSTextAlignmentCenter;
//设置垂直方向
//text1.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;
//字体颜色
text1.textColor = [UIColor redColor];
//字体大小
text1.font =[UIFont systemFontOfSize:25];
//设置自适应 如果字体内容超出 范围 那么这时可以自适应
text1.adjustsFontSizeToFitWidth = YES;
//设置最小字体
text1.minimumFontSize = 15;
//textField 只能显示一行
//设置清楚按钮
text1.clearButtonMode = UITextFieldViewModeAlways;
//下次进入编辑模式的时候是否清楚之前内容;
text1.clearsOnBeginEditing = YES;
//设置键盘风格(数子键盘 电话键盘 邮箱键盘
text1.keyboardType = UIKeyboardTypeDefault;
//键盘的颜色
text1.keyboardAppearance = UIKeyboardAppearanceLight;
/**
* return 键的类型
*/
text1.returnKeyType = UIReturnKeyGo;
//设置输入的英文首字母
text1.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters;
//设置自动纠错
text1.autocorrectionType =UITextAutocorrectionTypeNo;
[self.view addSubview:text1];
[text1 release];
//获取一个frame y+ height的值
CGFloat y= CGRectGetMaxY(text1.frame);
NSLog(@"y:%f",y);
UITextField *text2 = [[UITextField alloc]initWithFrame:CGRectMake(pendding, y+20, KScreenSize.width-2*pendding, 30)];
text2.borderStyle =UITextBorderStyleLine;
text2.secureTextEntry = YES;
[self.view addSubview:text2];
[text2 release];
}