RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
iOSUITextField的基本用法-创新互联

UITextField *textField = [[UITextField alloc] init];//初始化

成都网站建设哪家好,找创新互联!专注于网页设计、成都网站建设、微信开发、小程序制作、集团成都定制网站等服务项目。核心团队均拥有互联网行业多年经验,服务众多知名企业客户;涵盖的客户类型包括:成都广告设计等众多领域,积累了大量丰富的经验,同时也获得了客户的一致好评!

  textField.userInteractionEnabled = YES;//是否可用

  textField.text = @"UITextField"; //文字

  textField.delegate = self; //代理

  textField.frame = CGRectMake(100, 100, 100, 40); //大小和位置

  textField.textColor = [UIColor redColor];//  字体颜色

  textField.placeholder = @"UITextField";//提示字符

  [textField setBorderStyle:UITextBorderStyleRoundedRect]; //外框类型UITextBorderStyleRoundedRect枚举类型

  textField.secureTextEntry = YES; //密码框

  textField.clearButtonMode = UITextFieldViewModeWhileEditing; //编辑时会出现个修改X

  UIImageView *imgv=[[UIImageView alloc] initWithImage:[UIImage p_w_picpathNamed:@"right.png"]];

  textField.rightView=imgv;

  textField.rightViewMode = UITextFieldViewModeAlways; //右侧加图片

  textField.font = [UIFont systemFontOfSize:14.0f];//文字的大小

  textField.font = [UIFont boldSystemFontOfSize:14.0f];//文字加粗

  textField.autocapitalizationType = UITextAutocapitalizationTypeNone; //首字母是否自动大写

  textField.clearsOnBeginEditing = YES;  //再次编辑就清空

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

  textField.minimumFontSize = 20;  //设置自动缩小显示的最小字体大小

  textField.keyboardType = UIKeyboardTypeNumberPad;  //设置键盘的样式

  textField.backgroundColor = [UIColor grayColor];//背景颜色

  //placeholder 颜色

  //第一种

  UIColor *color = [UIColor whiteColor];

  textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}];

  //第二种

  [textField setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];//_placeholderLabel.textColor这个不可以修改

  textField.returnKeyType =UIReturnKeyDone;  //return键变成什么键

  //文字上下居中

  textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

  //文字左右居中

  textField.textAlignment = NSTextAlignmentCenter;

 textField.keyboardAppearance=UIKeyboardAppearanceDefault; //键盘外观

  //UITextField左边的距离

  CGRect frame = [textField frame];

  frame.size.width = 15;

  UIView *leftview = [[UIView alloc] initWithFrame:frame];

  textField.leftViewMode = UITextFieldViewModeAlways; //左边距为15pix

  textField.leftView = leftview;

  [textField becomeFirstResponder];//成为第一响应者

  [self.view addSubview:textField];

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


本文题目:iOSUITextField的基本用法-创新互联
文章路径:http://cqwzjz.cn/article/eeihp.html