zoukankan      html  css  js  c++  java
  • UITextField用法

    1.创建
    01.UITextField* textField = [[UITextField alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];  
    
    2.设置委托
    //委托类需要遵守UITextFieldDelegate协议  
    01.textField.delegate = self;
    
    3.设置属性UIControl属性对UITextField完全可以用,下面的都是UITextField扩展的属性
    
    //默认就是左对齐,这个是UITextField扩展属性  
    01.textField.textAlignment = UITextAlignmentLeft;
     
    //默认是没有边框,如果使用了自定义的背景图片边框会被忽略掉  
    02.textField.borderStyle = UITextBorderStyleBezel;
     
    //为空白文本字段绘制一个灰色字符串作为占位符  
    03.textField.placeholder = @"请在此输入账号";
     
    //设置为YES当用点触文本字段时,字段内容会被清除  
    04.textField.clearsOnBeginEditing = YES;
     
    //设置为YES时文本会自动缩小以适应文本窗口大小。默认是保持原来大小,而让长文本滚动 
    05.textField.adjustsFontSizeToFitWidth = YES; 
     
    //可以接受UIImage对象,此项设置则边框失效。  
    06.textField.background = [UIImage imageNamed:@"registBtn"];
    
     //右边显示的'X'清楚按钮  
    07.textField.clearButtonMode = UITextFieldViewModeUnlessEditing;
     //文本垂直居中
    08 textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
  • 相关阅读:
    记忆点
    数组的操作
    console.log()中的运算与打印事件
    ie9上传后下载json
    mysql使用on duplicate key update批量更新数据
    vue 弹出菜单
    mysql备份脚本
    uniapp+nodejs微信支付小程序版
    mycat初体验
    vscode格式化html标签属性不换行(vetur插件)
  • 原文地址:https://www.cnblogs.com/wangshengl9263/p/3241070.html
Copyright © 2011-2022 走看看