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;

    }
  • 相关阅读:
    HDU4112
    HDU1059 二进制拆分优化多重背包
    HDU1087
    HDU1978How Many Ways 记忆化dfs+dp
    HDU1160FatMouse's Speed
    HDU1503Advanced Fruits
    CF337C
    337BRoutine Problem
    【★★★★★模板专区★★★★★】
    【水】Jam计数法
  • 原文地址:https://www.cnblogs.com/daguo/p/2618813.html
Copyright © 2011-2022 走看看