textField 基本属性

 

_textField.frame = CGRectMake(0, 0, 200, 50);

_textField.delegate = self;

_textField.text = str;

[_textField becomeFirstResponder];

/*

设置背景色、背景图片。设置了背景图片后,背景色设置无效

如果background为nil,disabledBackground无效

*/

_textField.background = [UIImage imageNamed:@"返回-按下"];

_textField.disabledBackground = [UIImage imageNamed:@"返回-未激活"];

//    _textField.enabled = NO;

_textField.backgroundColor = [UIColor blueColor];

_textField.placeholder = @"输入文本…";

/*

设置为YES时文本会自动缩小以适应文本窗口大小.默认是保持原来大小,而让长文本滚动

*/

_textField.adjustsFontSizeToFitWidth = YES;

//设置自动缩小显示的最小字体大小,adjustsFontSizeToFitWidth为YES才会起作用

_textField.minimumFontSize = 20;

_textField.font = [UIFont systemFontOfSize:30.0f];

/*

内容对齐方式

内容的垂直对齐方式  UITextField继承自UIControl,此类中有一个属性contentVerticalAlignment

*/

_textField.textAlignment = UITextAlignmentLeft;

_textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

/*

typedef enum {

UITextBorderStyleNone,

UITextBorderStyleLine,

UITextBorderStyleBezel,

UITextBorderStyleRoundedRect

} UITextBorderStyle;

*/

_textField.borderStyle = UITextBorderStyleBezel;

/*

每输入一个字符就变成点 用语密码输入

*/

_textField.secureTextEntry = NO;

/*

//输入框中是否有个叉号,在什么时候显示,用于一次性删除输入框中的内容

typedef enum {

UITextFieldViewModeNever, 重不出现

UITextFieldViewModeWhileEditing, 编辑时出现

UITextFieldViewModeUnlessEditing, 除了编辑外都出现

UITextFieldViewModeAlways  一直出现

} UITextFieldViewMode;

*/

_textField.clearButtonMode = UITextFieldViewModeWhileEditing;

/*

开始编辑,清空数据

*/

_textField.clearsOnBeginEditing = NO;

/*

//是否纠错

typedef enum {

UITextAutocorrectionTypeDefault, 默认

UITextAutocorrectionTypeNo,  不自动纠错

UITextAutocorrectionTypeYes, 自动纠错

} UITextAutocorrectionType;

*/

_textField.autocorrectionType = UITextAutocorrectionTypeYes;

/*

//首字母是否大写

typedef enum {

UITextAutocapitalizationTypeNone, 不自动大写

UITextAutocapitalizationTypeWords, 单词首字母大写

UITextAutocapitalizationTypeSentences, 句子的首字母大写

UITextAutocapitalizationTypeAllCharacters, 所有字母都大写

} UITextAutocapitalizationType;

*/

_textField.autocapitalizationType = UITextAutocapitalizationTypeWords;

/*

键盘

typedef enum {

UIKeyboardTypeDefault,      默认键盘,支持所有字符

UIKeyboardTypeASCIICapable, 支持ASCII的默认键盘

UIKeyboardTypeNumbersAndPunctuation, 标准电话键盘,支持+*#字符

UIKeyboardTypeURL,            URL键盘,支持.com按钮 只支持URL字符

UIKeyboardTypeNumberPad,             数字键盘

UIKeyboardTypePhonePad,   电话键盘

UIKeyboardTypeNamePhonePad,  电话键盘,也支持输入人名

UIKeyboardTypeEmailAddress,  用于输入电子 邮件地址的键盘

UIKeyboardTypeDecimalPad,    数字键盘 有数字和小数点

UIKeyboardTypeTwitter,       优化的键盘,方便输入@、#字符

UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable,

} UIKeyboardType;

*/

_textField.keyboardType = UIKeyboardTypeDefault;

/*

//return键变成什么键

typedef enum {

UIReturnKeyDefault, 默认 灰色按钮,标有Return

UIReturnKeyGo,     标有Go的蓝色按钮

UIReturnKeyGoogle,标有Google的蓝色按钮,用语搜索

UIReturnKeyJoin,标有Join的蓝色按钮

UIReturnKeyNext,标有Next的蓝色按钮

UIReturnKeyRoute,标有Route的蓝色按钮

UIReturnKeySearch,标有Search的蓝色按钮

UIReturnKeySend,标有Send的蓝色按钮

UIReturnKeyYahoo,标有Yahoo的蓝色按钮

UIReturnKeyYahoo,标有Yahoo的蓝色按钮

UIReturnKeyEmergencyCall, 紧急呼叫按钮

} UIReturnKeyType;

*/

_textField.returnKeyType = UIReturnKeyDone;

/*

//键盘外观

typedef enum {

UIKeyboardAppearanceDefault, 默认外观,浅灰色

UIKeyboardAppearanceDark,   深灰 石墨色

UIKeyboardAppearanceLight 浅灰色

} UIReturnKeyType;

*/

_textField.keyboardAppearance=UIKeyboardAppearanceDefault;

/*

设置左右的两个view

*/

//    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_right"]];

//    imgView.frame = CGRectMake(0, 0, 20, 20);

//    _textField.rightView = imgView;

//    _textField.rightViewMode = UITextFieldViewModeAlways;   // 同上

UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_left"]];

imgView.frame = CGRectMake(0, 0, 20, 20);

_textField.leftView = imgView;

_textField.leftViewMode = UITextFieldViewModeAlways;   // 同上

/*

重写绘制行为

除了UITextField对象的风格选项,你还可以定制化UITextField对象,为他添加许多不同的重写方法,来改变文本字段的显示行为。这些方法都会返回一个CGRect结构,制定了文本字段每个部件的边界范围。以下方法都可以重写。

– textRectForBounds:     //重写来重置文字区域

– drawTextInRect:         //改变绘文字属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了.

– placeholderRectForBounds:  //重写来重置占位符区域

– drawPlaceholderInRect:  //重写改变绘制占位符属性.重写时调用super可以按默认图形属性绘制,若自己完全重写绘制函数,就不用调用super了.

– borderRectForBounds:  //重写来重置边缘区域

– editingRectForBounds:  //重写来重置编辑区域

– clearButtonRectForBounds:  //重写来重置clearButton位置,改变size可能导致button的图片失真

– leftViewRectForBounds:

– rightViewRectForBounds:

*/

UITextFeild的基本属性的更多相关文章

  1. jQuery插件:jqGrid引入及基本属性

    1. jqGrid下载 jqGrid下载地址: http://www.trirand.com/blog/ jqGrid Demo: http://www.guriddo.net/demo/guridd ...

  2. Material Design 概念,环境和基本属性

    Material Design 概念,环境和基本属性 Material Design是随Android 5.0推出的一种设计概念, 涉及到了跨平台和设备的视觉,动态,交互设计等方面.   设计概念 M ...

  3. CSS2中基本属性的介绍

    这是继上一篇的选择器的总结,对css2基本属性的小结!

  4. 内省、JavaBean、PropertyDescriptor类、Introspector类、BeanUtils工具包、注解、Rentention、Target、注解的基本属性和高级属性

      本文转载自:http://blog.sina.com.cn/s/blog_5d65a16901011kom.html 关键字:内省.JavaBean.PropertyDescriptor类.Int ...

  5. C#-WinForm-客户端程序-Form基本属性

    WinForm - 客服端程序(C/S) WindowsForm 的简称 客户端应用程序:是需要安装在用户电脑上才可以使用的程序,代码部分在用户电脑上执行 特点:不需要联网也可以打开使用部分功能,但现 ...

  6. iOS关于UILabel 基本属性 背景图片 背景色

    [代码] iOS关于UILabel 基本属性 背景图片 背景色 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...

  7. asp.net Login控件基本属性及事件说明

    原文:asp.net Login控件基本属性及事件说明 Login系列控件是微软为了简化我们的开发过程,为我们进行常规的安全开发提供块捷途径. Login系列控件包含下列控件: Login 登录控件 ...

  8. Away 3d 基本属性

    出处:http://blog.sina.com.cn/s/blog_59f0ac9d0101ci2j.html View3D在初始化时候就已经创建的Camera3D 所以有时候没有创建Camera3D ...

  9. Javascript数组(1)--基本属性及方法

    数组Array是Javascript语言中非常重要的两种引用类型数据之一,另外一种为对象Object.Array的数据模型可分为两种进行存储:堆栈结构.队列结构. 昨天,确切说是前天了,去和大学同学见 ...

随机推荐

  1. GSON使用笔记(3) -- 如何反序列化出List

    GSON使用笔记(3) -- 如何反序列化出List 时间 2014-06-26 17:57:06  CSDN博客原文  http://blog.csdn.net/zxhoo/article/deta ...

  2. java多条件查询SQL语句拼接的小技巧

    问题: 一个界面有个多个文本框输入值(或下拉框)展示的查询条件,也就是组合条件查询,需要在java里面动态拼接SQL,where条件如何写? 解决思路: 在where关键字后面固定写 1=1, 若还有 ...

  3. 使用 Visual Studio Code 进行 Laravel 开发(转)

    转自:https://laravelacademy.org/post/8016.html 关于 Laravel 代码开发工具大家各有所好,大部分应该在用 PHPStorm,Sublime 也有很多粉丝 ...

  4. P1090 危险品装箱

    1090 危险品装箱 (25分)   集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里.比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸. 本题给定一张不相容物品的清单,需要你 ...

  5. Kubernetes v1.17.3 CentOS8 基于kuberadm安装

    1.机器配置: IP 主机名 节点类型 配置 192.168.31.32 node32 master 4核16G 192.168.31.33 node33 worker 4核16G 192.168.3 ...

  6. login SMTP send mail error : Unable to read data from the transport connection: net_io_connectionclosed

    client.Credentials = new NetworkCredential(sSMTPuser, sSMTPpass); client.Credentials = new NetworkCr ...

  7. php笔记04

    PHP+MySQL 连接数据库 mysqli <?php $servername="localhost"; $username="root"; $pass ...

  8. thinkphp配置到二级目录,不配置到根目录,访问除首页的其他路径都是404报错

    1.在nginx的配置里面,进行重定向 vi /etc/nginx/conf.d/default.conf 2.进入编辑 location /thinkphp/public { if (!-e $re ...

  9. 微服务中springboot启动问题

    log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardS ...

  10. Spring-IOC(基于XML配置)

    什么是IOC? IOC: Inversion of Control(控制反转). 控制反转:将对象的创建权反转给(交给)Spring. 在使用Spring框架之后,对象的实例不再由调用者来创建,而 是 ...