zoukankan      html  css  js  c++  java
  • UITextField

    UITextField:文本输入框

        // 创建一个textField
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(60, 40, 200, 30)];
        
        textField.backgroundColor = [UIColor lightGrayColor]; // 通常不设置
        textField.text = @"测试"; // 通常不设置
        
        textField.placeholder = @"手机号/邮箱"; // 背景显示内容
        textField.secureTextEntry = YES; // 密码模式
        textField.returnKeyType = UIReturnKeyGo; // 键盘右下角 return 换成go
        
        // 修改textField弹出来的视图,系统键盘(替换键盘 x y 宽 设置无用)
        textField.inputView = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 100)] autorelease];
        UIView *accessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
        accessoryView.backgroundColor = [UIColor yellowColor]; // 透明色 clearColor
       textField.inputAccessoryView = accessoryView; // 添加辅助视图 紧挨键盘在其上面
        [accessoryView release];
        
        textField.borderStyle = UITextBorderStyleRoundedRect; // 边框
        
        textField.clearButtonMode = UITextFieldViewModeAlways; // 输入框右侧删除按钮
        
        // 给textField添加左视图
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 30)];   
        label.text = @"用户名";
        textField.leftView = label;
        textField.leftViewMode = UITextFieldViewModeAlways; // 添加左视图
        [label release];
        
        // 自动首字母大写
        textField.autocapitalizationType = UITextAutocapitalizationTypeNone; // 关上
        
        // 自动修正功能
        textField.autocorrectionType = UITextAutocorrectionTypeNo; // 关上
    

      

  • 相关阅读:
    JavaScript传递参数方法
    IScroll5不能滑到最底端的解决办法
    VS Less Compiler插件使用
    Sql查询某个字段是否包含小写字母
    试用VS2019正式版
    Ext.net MessageBox提示
    VS打开项目 提示Asp.net4.0未在web服务器上注册的解决方案
    罗技M185鼠标飘
    Ext.Net的一例Ext Undefined解决办法
    JGUI源码:DataTable固定列样式(20)
  • 原文地址:https://www.cnblogs.com/sqdhy-zq/p/4750519.html
Copyright © 2011-2022 走看看