zoukankan      html  css  js  c++  java
  • UITextField详解

    一、UITextField

    (1)初始化UITextField

    UITextField* text = [[UITextField alloc] initWithFrame:CGRectMake(10, 50, 300, 30)];
    
        text.borderStyle = UITextBorderStyleRoundedRect;
    
        text.autocorrectionType = UITextAutocorrectionTypeYes;
    
        text.placeholder = @"XXXXXXX";
    
        text.returnKeyType = UIReturnKeyDone;
    
        text.clearButtonMode = UITextFieldViewModeWhileEditing;
    
        [text setBackgroundColor:[UIColor whiteColor]];
    
        text.delegate = self;
    
        [self.view addSubview:text];
    

    (2)详细参数解释

    borderStyle:文本框的边框风格

    autocorrectionType:可以设置是否启动自动提醒更正功能。

    placeholder:设置默认的文本显示

    returnKeyType:设置键盘完成的按钮

    backgroundColor:设置背景颜色

    delegate:设置委托

    (3)委托方法

    -(void)textFieldDidBeginEditing:(UITextField *)textField;

    //当开始点击textField会调用的方法



    -(void)textFieldDidEndEditing:(UITextField *)textField;

    //当textField编辑结束时调用的方法

    //按下Done按钮的调用方法,我们让键盘消失

    -(BOOL)textFieldShouldReturn:(UITextField *)textField{

    [textField resignFirstResponder];

    return YES;

    }
  • 相关阅读:
    Lock和synchronized的区别和使用(转发)
    redis集群配置
    分布式之redis(转发)
    拉格朗日乘法与KKT条件
    骨骼动画原理
    常用非线性优化算法总结
    广义线性回归模型(三)
    线性模型、最优化方法(二)
    矩阵微分基础(一)
    OpenGL坐标系统
  • 原文地址:https://www.cnblogs.com/daguo/p/2618813.html
Copyright © 2011-2022 走看看