zoukankan      html  css  js  c++  java
  • uitextfield的常用属性

        //文本框
        UITextField *textField=[[UITextField alloc] initWithFrame:CGRectMake(50, 50, 200, 50)];
        //textField.backgroundColor=[UIColor yellowColor];
        
    //文本显示设置
        //文字
        textField.text=@"110";//提前输入的文字,可以删除
        //文字颜色
        textField.textColor=[UIColor redColor];
        //文字对其位置
        textField.textAlignment=NSTextAlignmentRight;
        //文字大小
        textField.font=[UIFont systemFontOfSize:25];
        //输入提示
        textField.placeholder=@"请输入";
    //输入控制设置
        //是否允许输入,YES允许输入,NO不允许输入,默认为YES
        //textField.enabled=YES;
        //是否清空(开始输入是否清空之前文字.默认NO)
        textField.clearsOnBeginEditing=YES;
        //密码
        textField.secureTextEntry=YES;
        //键盘
        textField.keyboardType=UIKeyboardTypeNumberPad;//纯数字键盘
        
        
        
        UIView *keyBoardView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        keyBoardView.backgroundColor=[UIColor redColor];
        //1.取代键盘位置的view,以后可以自己定义按钮输入
        //textField.inputView=keyBoardView;
        
        //2.在原来键盘上面 ,加一块view,上部可以实现自定义按钮输入
        textField.inputAccessoryView=keyBoardView;
        
        
        
    //外观设置
        //输入框形状
        textField.borderStyle=UITextBorderStyleRoundedRect;
        
        
        
        UIImageView *imV=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"2.png"]];
        imV.frame=CGRectMake(0, 0, 50, 50);
        //在文本框左边显示一张图片
        textField.leftView=imV;
        textField.leftViewMode=UITextFieldViewModeAlways;
        
        
        UIImageView *imV1=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1.png"]];
        imV1.frame=CGRectMake(0, 0, 50, 50);
        //在文本框右边显示一张图片
        textField.rightView=imV1;
        textField.rightViewMode=UITextFieldViewModeAlways;
        
        //清楚文本内部文字 按钮
        textField.clearButtonMode=UITextFieldViewModeAlways;
        
        
        [backGroundView addSubview:textField];
        

  • 相关阅读:
    渗透测试靶场
    Ubuntu kylin优麒麟下配置Hadoop环境
    虚拟机win+IIs+asp+access搭建网站过程
    百度增强搜索
    渗透入门——术语概述
    api如何获取cookie
    还在纠结接口文档的事儿呢?
    为什么需要API管理平台
    自动生成接口文档的三种方式
    轻量化API测试工具整理
  • 原文地址:https://www.cnblogs.com/-ios/p/4672578.html
Copyright © 2011-2022 走看看