iOS UITextField 文本输入框 详解

UITextField

 1 - (void)viewDidLoad
 2 {
 3     // UITextField属性总结下,例如下面的:
 4     UIImageView * myView = [[ UIImageView  alloc]initWithImage:[UIImage imageNamed:@"face.png"]];
 5     UIImageView * myView2 = [[ UIImageView  alloc]initWithImage:[UIImage imageNamed:@"face2.png"]];
 6     UITextField *nameField=[[UITextField alloc]initWithFrame:CGRectMake(40, 40, 240, 60)]; //初始化一个UITextField的frame
 7     
 8     nameField.textColor=[UIColor redColor];  //UITextField 的文字颜色
 9     nameField.delegate=self;//UITextField 代理方法设置
10     nameField.placeholder=@"输入密码";//UITextField 的初始隐藏文字,当然这个文字的字体大小颜色都可以改,重写uitextfield,下次介绍
11     nameField.textAlignment=NSTextAlignmentLeft;//UITextField 的文字对齐格式
12     nameField.font=[UIFont fontWithName:@"Times New Roman" size:30];//UITextField 的文字大小和字体
13     nameField.adjustsFontSizeToFitWidth=YES;//UITextField 的文字自适应
14     nameField.clearsOnBeginEditing=NO;//UITextField 的是否出现一件清除按钮
15     nameField.borderStyle=UITextBorderStyleNone;//UITextField 的边框
16     nameField.background=[UIImageimageNamed:@"my.png"];//UITextField 的背景,注意只有UITextBorderStyleNone的时候改属性有效
17     nameField.clearButtonMode=UITextFieldViewModeNever;//UITextField 的一件清除按钮是否出现
18     nameField.leftView=myView;//UITextField 的左边view
19     nameField.leftViewMode=UITextFieldViewModeAlways;//UITextField 的左边view 出现模式
20     nameField.rightView=myView2;//UITextField 的有边view
21     nameField.rightViewMode=UITextFieldViewModeAlways;//UITextField 的右边view 出现模式
22     nameField.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;//UITextField 的字的摆设方式
23     [myView release];
24     [myView2 release];
25     [self.view addSubview:nameField];
26 }

UITextField的总结

获取UITableViewCell中UITextField的值方法总结

限制UITextField输入的类

https://github.com/detecyang/TextFilter

UITextField如何设置背景图 

UITextField 的背景,只有UITextBorderStyleNone的时候改属性有效 

 txtUserPass.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:@"logintxtbg.png"]];

IOS中在View的空白处UITextField取消第一响应方法

1.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [m_textField resignFirstResponder];
}

2,[self.view endEditing:YES];比较好 

 

ABAddressBook个人使用总结,联系人中、英文排序及中、英文及号码搜索

http://www.cocoachina.com/bbs/read.php?tid=38851&page=1

原文地址:https://www.cnblogs.com/hl666/p/3702518.html