UITextField属性一
来源:互联网 发布:海信网络机顶盒ip903h 编辑:程序博客网 时间:2024/05/21 09:31
01、创建TextField
//创建TextField UITextField *myTextField = [[UITextField alloc] init]; //设置大小 myTextField.frame = CGRectMake(70, 150, 200, 30); //背景颜色 myTextField.backgroundColor = [UIColor magentaColor]; //添加到当前视图显示 [self.view addSubview:myTextField];
02、center//将myTextField置于当前视图的中心 myTextField.center = self.view.center;
03、 text//输入文本 myTextField.text = @"世界, 你好!";
04、placeholder //占位符myTextField.placeholder = @"请输入信息";
05、textColor//设置字体颜色 myTextField.textColor = [UIColor redColor];
06、textAlignment 文本对齐方式//文本文字横向居中 myTextField.textAlignment = NSTextAlignmentCenter;
07、enablesReturnKeyAutomatically//默认为No,如果设置为Yes,文本框中没有输入任何字符的话,右下角的返回按钮是disabled的。如果文本框中已经输入字符,则不禁用。 myTextField.enablesReturnKeyAutomatically = YES;
08、borderStyle 设置边框样式,只有设置了才会显示边框样式 //圆角 myTextField.borderStyle = UITextBorderStyleRoundedRect; typedef enum { UITextBorderStyleNone, UITextBorderStyleLine, UITextBorderStyleBezel, UITextBorderStyleRoundedRect } UITextBorderStyle;
09、background 背景图片//background 背景图片 myTextField.background = [UIImage imageNamed:@"navbar_bg_normal-64"];注意:当UITextField的属性borderStyle设置为UITextBorderStyleRoundedRect的时候,background设置是无效的,即: //圆角形式 myTextField.borderStyle = UITextBorderStyleRoundedRect; //background 背景图片 myTextField.background = [UIImage imageNamed:@"navbar_bg_normal-64"];
10、font 字体//设置输入框内容字体的大小 myTextField.font = [UIFont systemFontOfSize:17];//设置输入框内容字体的样式和大小 myTextField.font = [UIFont fontWithName:@"Arial" size:20];
11、clearButtonMode 清除文本按钮模式:输入框会有一个×号,用于一次性清除文本内容//编辑的时候出现 myTextField.clearButtonMode = UITextFieldViewModeWhileEditing;属性有如下: typedef NS_ENUM(NSInteger, UITextFieldViewMode) { UITextFieldViewModeNever, //重不出现 UITextFieldViewModeWhileEditing, //编辑时出现 UITextFieldViewModeUnlessEditing,//除了编辑的时候都出现 UITextFieldViewModeAlways //总是出现 };
12、secureTextEntry //安全文本模式,一般用于输入密码时需要,每输入一个字符就会变成“.”。 myTextField.secureTextEntry = YES; //默认是NO
13、autocorrectionType键盘自动纠正类型属性有:typedef NS_ENUM(NSInteger, UITextAutocorrectionType) { UITextAutocorrectionTypeDefault, //默认 UITextAutocorrectionTypeNo, //不自动纠错 UITextAutocorrectionTypeYes, //自动纠错 };//会自动纠正myTextField.autocorrectionType = UITextAutocorrectionTypeYES;DEMO如图:![这里写图片描述](http://img.blog.csdn.net/20160702190941020)//不会自动纠正 myTextField.autocorrectionType = UITextAutocorrectionTypeNo;DEMO如图:![这里写图片描述](http://img.blog.csdn.net/20160702191107725)
1 0
- UITextField属性一
- uitextfield 属性
- UITextField属性
- UITextField 属性
- UITextField属性
- UITextField属性
- UITextField属性 UITextView属性
- iPhone UITextField 属性
- UITextField 属性讲解
- iPhone UITextField 属性
- UITextField控件的属性
- UITextField控件的属性
- UITextField控件的属性
- UITextField属性详解
- iPhone UITextField 属性
- UITextField 属性讲解
- UITextField属性设置
- UITextField 属性讲解
- Notepad++ 添加lua Functionlist
- Java HashMap工作原理及实现
- js dom 操作实例图解
- 进入setting的组件应用程序信息
- 安卓学习之—Fragment
- UITextField属性一
- 【C/C++】求最大公约数的三种方法
- java继承
- 知识管理,浏览器收藏夹,经常访问的网站
- linux网络通信并发程序设计(一)
- UNIX网络编程——概述
- JS笔记3-笔记整理自智能社JS教程
- 管道,匿名管道及其命名管道的解析
- java多线程解决同步问题的几种方式、原理和代码