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

      

  • 相关阅读:
    [ICPC2016上海F] Mr. Panda and Fantastic Beasts
    [ICPC2016上海E] Bet
    [ICPC2016上海D] Ice Cream Tower
    [ICPC2016上海L] World Cup
    [CCPC2020长春F] Strange Memory
    [CF1495C] Garden of the Sun
    【实战】牛年的第一个SQL注入漏洞
    【实战】一次有趣的HPP绕WAF记录
    [模板]二分答案
    字典树及其应用
  • 原文地址:https://www.cnblogs.com/sqdhy-zq/p/4750519.html
Copyright © 2011-2022 走看看