zoukankan      html  css  js  c++  java
  • UITextField

     1 @synthesize textField = _textField;
     2 
     3 
     4 - (void)viewDidLoad {
     5     [super viewDidLoad];
     6     
     7     self.textField = [[UITextField alloc]init];
     8     
     9     self.textField.frame = CGRectMake(100, 100, 180, 40);
    10     
    11     self.textField.text = @"UserName";
    12     
    13     self.textField.font = [UIFont systemFontOfSize:15];
    14     
    15     self.textField.textColor = [UIColor blackColor];
    16     
    17     //边框风格
    18     self.textField.borderStyle = UITextBorderStyleBezel;
    19     
    20     //设置虚拟键盘风格
    21     //self.textField.keyboardType = UIKeyboardTypeDefault;
    22     
    23     self.textField.keyboardType = UIKeyboardTypeNumberPad;
    24     
    25     
    26     //设置文字提示信息,默认浅灰色,当文本框内什么都没有才显示
    27     self.textField.placeholder = @"Input username";
    28     
    29     //是否作为密码输入
    30     self.textField.secureTextEntry = YES;
    31 
    32     [self.view addSubview:self.textField];
    33 }
    34 
    35 //在屏幕空白处点击
    36 -(void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
    37 {
    38     //不再作为消息的第一响应者
    39     [self.textField resignFirstResponder];
    40 }
    @interface ViewController : UIViewController<UIAlertViewDelegate>
    {
    
        UITextField* _textField;
    }
    
    //属性定义
    @property(retain,nonatomic) UITextField* textField;
  • 相关阅读:
    perimeter of squares
    map
    django路由
    for的骚用法
    3和5的倍数相加和
    PeteCake 字典和最小值
    Find the missing letter
    实现简单的ssh功能
    开源运维工具体系
    vsftp在iptables中的配置
  • 原文地址:https://www.cnblogs.com/vector11248/p/7600623.html
Copyright © 2011-2022 走看看