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];
        

  • 相关阅读:
    【mysql】mac上基于tar.gz包安装mysql服务
    【maven】在idea上创建maven多模块项目
    关于Class.getResource和ClassLoader.getResource的路径问题
    【maven】Maven打包后为何文件大小改变了
    git常用命令
    第一章 第一个spring boot程序
    第二章 eclipse中m2e插件问题
    第一章 mac下开发环境的配置
    第一章 开发中遇到的错误列表
    第十一章 企业项目开发--消息队列activemq
  • 原文地址:https://www.cnblogs.com/-ios/p/4672578.html
Copyright © 2011-2022 走看看