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; // 关上
    

      

  • 相关阅读:
    诸侯安置
    可可西里
    直线交点
    切割多边形
    ACM挑战程序设计竞赛1.1抽签
    朝鲜战争:轰炸大小和岛
    星际争霸II 战斗问题
    乒乓球
    瑞士轮
    NOIP 2010 普及组解题报告
  • 原文地址:https://www.cnblogs.com/sqdhy-zq/p/4750519.html
Copyright © 2011-2022 走看看