• UITextField 详解


     1 UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(20, 20, 280, 30)];
     2     tf.borderStyle = UITextBorderStyleNone; // 无边框线
     3     // UITextBorderStyleBezel(边框+阴影) ,UITextBorderStyleLine(边框线) ,UITextBorderStyleRoundedRect(圆角+阴影) 按钮样式
     4     tf.text = @"xxxxx";                 // 内容
     5     tf.placeholder = @"请输入姓名";       // 站位字符
     6     [tf becomeFirstResponder];          // 成为第一响应者,显示键盘
     7     [tf resignFirstResponder];          // 失去第一响应者,隐藏键盘
     8     
     9     tf.backgroundColor = [UIColor redColor];    // 背景色
    10     tf.textColor = [UIColor greenColor];        // 字体颜色
    11     tf.background = [UIImage imageNamed:@"background.png"]; // 设置背景图
    12     
    13     tf.clearButtonMode = UITextFieldViewModeNever;  //  没有清空按钮
    14     tf.clearButtonMode = UITextFieldViewModeAlways; //  始终存在清空按钮
    15     tf.clearButtonMode = UITextFieldViewModeWhileEditing;   // 在编辑时有清空按钮
    16     tf.clearButtonMode = UITextFieldViewModeUnlessEditing;  // 编辑时没有清空按钮,其他时候都存在
    17     
    18     tf.clearsOnBeginEditing = YES;  //当编辑时,自动清空内容
    19     
    20     UIImageView *vv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"left.png"]];
    21     tf.leftView = vv;   // 设置左侧图片
    22     tf.rightView = vv;  // 设置右侧图片
    23     tf.rightViewMode = tf.leftViewMode = UITextFieldViewModeAlways; //左右图片始终存在
    24     
    25     // UITextFieldDelegage UITextField监控代理
  • 相关阅读:
    打开外部程序
    检测是否渲染
    maxsxript 坐标转换 函数
    实用 SQL 语句
    【整理】一些有用的学习资源链接
    关于 static 和 final 的一些理解
    Java8新特性时间日期库
    推荐一套后台管理系统
    Java API 之 Object
    【软件体系结构】架构风格与基于网络应用软件的架构设计
  • 原文地址:https://www.cnblogs.com/sell/p/2891827.html
Copyright © 2020-2023  润新知