zoukankan      html  css  js  c++  java
  • UITextfile属性方法大全

     //初始化textfield并设置位置及大小

          UITextField *textField = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];

          //设置边框样式,只有设置了才会显示边框样式 

          textField.borderStyle = UITextBorderStyleRoundedRect;

          typedef enum {

          UITextBorderStyleNone, 

          UITextBorderStyleLine,

          UITextBorderStyleBezel,

          UITextBorderStyleRoundedRect  

          } UITextBorderStyle;

          //设置输入框的背景颜色,此时设置为白色 如果使用了自定义的背景图片边框会被忽略掉  

          textField.backgroundColor = [UIColor whiteColor];

          //设置背景

          textField.background = [UIImage imageNamed:@"dd.png"];

          //设置背景 

          textField.disabledBackground = [UIImage imageNamed:@"cc.png"];

          //当输入框没有内容时,水印提示 提示内容为password

          textField.placeholder = @"password";

          //设置输入框内容的字体样式和大小

          textField.font = [UIFont fontWithName:@"Arial" size:20.0f];

          //设置字体颜色

          textField.textColor = [UIColor redColor];

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

          textField.clearButtonMode = UITextFieldViewModeAlways;

          typedef enum {

          UITextFieldViewModeNever,  重不出现

          UITextFieldViewModeWhileEditing, 编辑时出现

          UITextFieldViewModeUnlessEditing,  除了编辑外都出现

          UITextFieldViewModeAlways   一直出现

          } UITextFieldViewMode;

          //输入框中一开始就有的文字

          textField.text = @"一开始就在输入框的文字";

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

          textField.secureTextEntry = YES;

          //是否纠错

          textField.autocorrectionType = UITextAutocorrectionTypeNo;

          typedef enum {

          UITextAutocorrectionTypeDefault, 默认

          UITextAutocorrectionTypeNo,   不自动纠错

          UITextAutocorrectionTypeYes,  自动纠错

          } UITextAutocorrectionType;

          //再次编辑就清空

          textField.clearsOnBeginEditing = YES; 

          //内容对齐方式

          textField.textAlignment = UITextAlignmentLeft;

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

          textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

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

          textField.adjustsFontSizeToFitWidth = YES;

          //设置自动缩小显示的最小字体大小

          textField.minimumFontSize = 20;

          //设置键盘的样式

          textField.keyboardType = UIKeyboardTypeNumberPad;

          typedef enum {

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

          UIKeyboardTypeASCIICapable,   支持ASCII的默认键盘

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

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

          UIKeyboardTypeNumberPad,   数字键盘

          UIKeyboardTypePhonePad,   电话键盘

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

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

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

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

          UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, 

          } UIKeyboardType;

          //首字母是否大写

          textField.autocapitalizationType = UITextAutocapitalizationTypeNone;

          typedef enum {

          UITextAutocapitalizationTypeNone, 不自动大写

          UITextAutocapitalizationTypeWords,  单词首字母大写

          UITextAutocapitalizationTypeSentences,  句子的首字母大写

          UITextAutocapitalizationTypeAllCharacters, 所有字母都大写

          } UITextAutocapitalizationType;

          //return键变成什么键

          textField.returnKeyType =UIReturnKeyDone;

          typedef enum {

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

          UIReturnKeyGo,      标有Go的蓝色按钮

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

          UIReturnKeyJoin,标有Join的蓝色按钮

          UIReturnKeyNext,标有Next的蓝色按钮

          UIReturnKeyRoute,标有Route的蓝色按钮

          UIReturnKeySearch,标有Search的蓝色按钮

          UIReturnKeySend,标有Send的蓝色按钮

          UIReturnKeyYahoo,标有Yahoo的蓝色按钮

          UIReturnKeyYahoo,标有Yahoo的蓝色按钮

          UIReturnKeyEmergencyCall, 紧急呼叫按钮

          } UIReturnKeyType;

          //键盘外观

          textView.keyboardAppearance=UIKeyboardAppearanceDefault;

          typedef enum {

          UIKeyboardAppearanceDefault, 默认外观,浅灰色

          UIKeyboardAppearanceAlert,     深灰 石墨色

          } UIReturnKeyType;

          //设置代理 用于实现协议

          textField.delegate = self;

          //把textfield加到视图中

          [self.window addSubview:

  • 相关阅读:
    检测单链表是否含有环
    巧用正则和document.location.search获取URL参数的值
    网站前端性能优化
    Ubuntu 10.10 wubi安装错误处理
    SQL中随机数函数rand()简介
    C#实现智能提示(提示补全)功能
    重装系统使之svn再次复活
    MongoDB安装
    mongodb查询
    解决iframe中跨域session丢失的问题
  • 原文地址:https://www.cnblogs.com/liumu/p/5256444.html
Copyright © 2011-2022 走看看