码迷,mamicode.com
首页 > 移动开发 > 详细

IOS 学习笔记---UITextField的一些属性

时间:2015-09-29 21:54:56      阅读:324      评论:0      收藏:0      [点我收藏+]

标签:

UITextField* textField=[[UITextField alloc]initWithFrame:CGRectMake(60, 100, 200, 30)];
    //属性
    //样式
  
    textField.borderStyle=UITextBorderStyleBezel;//矩形有阴影
    textField.borderStyle=UITextBorderStyleLine;//矩形没有阴影
    textField.borderStyle=UITextBorderStyleNone;//无边框
    textField.borderStyle=UITextBorderStyleRoundedRect;//边角为圆形
    
    textField.text=@"sdf";//默认字体
    textField.placeholder=@"在此输入。。。";//提示输入
    textField.textAlignment=NSTextAlignmentCenter;//居中
    textField.secureTextEntry=YES;//安全输入,密码框
    textField.clearButtonMode=UITextFieldViewModeWhileEditing;//设置文本框右边有个清除栏
    textField.keyboardType = UIKeyboardTypePhonePad; // 弹出的键盘的样式,弹出数组键盘
    textField.keyboardAppearance=UIKeyboardAppearanceAlert;//设置键盘的颜色为深灰,默认是浅灰色UIKeyboardAppearanceDefault
    textField.clearsOnBeginEditing = YES; // 再次编辑就清空原有的内容
    
    textField.minimumFontSize = 20.0f; // 设置自动缩小显示的最小字体大小
    textField.secureTextEntry = NO; // 设置是否以密码的圆点形式显示
    textField.autocorrectionType = YES; // 设置是否启动自动提醒更新功能
    textField.returnKeyType = UIReturnKeyDefault; // 设置弹出的键盘带形式与带的按键
    [self.view addSubview:textField];


//当开始点击textField会调用的方法

-(void)textFieldDidBeginEditing:(UITextField *)textField {
    
    NSLog(@"开始编辑");
    
}

//当textField编辑结束时调用的方法

-(void)textFieldDidEndEditing:(UITextField *)textField {
    
    NSLog(@"结束编辑");
    
}

//按下Done按钮的调用方法,我们让键盘消失

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [textField resignFirstResponder];
    
    return YES;
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

 

IOS 学习笔记---UITextField的一些属性

标签:

原文地址:http://www.cnblogs.com/mojiewei/p/4847242.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!