UITextField 学习知识点

it2022-05-06  6

//UITwxtField(输入框):是iOS中提供的用来显示文字和编辑文字的控件.

核心功能:文字编辑

//1.创建输入框对象

    UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(30, 100, 300, 40)];

    //2.配置相关属性

    tf.backgroundColor = [UIColor yellowColor];

    //2.1 设置提示文字 (VIP)

    tf.placeholder = @"请输入你的三围";

    //2.2 设置输入框内容 (VIP)

    tf.text = @"38";

    //2.3 设置文字颜色

    tf.textColor = [UIColor redColor];

    //2.4 设置文字对齐方式 -- 居中对齐

    tf.textAlignment = NSTextAlignmentCenter;

    //2.5 设置字体大小

    tf.font = [UIFont boldSystemFontOfSize:25];

    //2.6 当第一次选中输入框时,是否清除输入框内容.

    tf.clearsOnBeginEditing = YES;

    //2.7 设置清除按钮模式

    tf.clearButtonMode = UITextFieldViewModeWhileEditing;

    //2.8 设置输入框样式

    tf.borderStyle = UITextBorderStyleRoundedRect;

    //2.9 设置输入框能否编辑 -- 关闭用户交互 (NO)

    tf.userInteractionEnabled = YES;

    //2.10 设置键盘类型 -- 数字键盘

    //tf.keyboardType = UIKeyboardTypeNumberPad;

    //2.11 设置键盘外观样式

    tf.keyboardAppearance = UIKeyboardAppearanceDark;

    //2.12 设置输入框内容以安全模式显示

    tf.secureTextEntry = YES;

    //2.13 代理(检测输入框的各种行为)(VIP)

    tf.delegate = self;//代理指定为AppDelegate对象

   

    //3.添加到父视图

    [self.window addSubview:tf];

    //4.释放所有权

[tf release];

转载于:https://www.cnblogs.com/iamfoolish/p/4769866.html

相关资源:数据结构—成绩单生成器

最新回复(0)