UITextField

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(50, 200, 200, 40)];
    //设置输入框的边框样式
    textField.borderStyle = UITextBorderStyleRoundedRect;
    
    //设置输入框显示的占位符
    //告诉用户这个输入框应该输入的信息。
    textField.placeholder = @"请输入你最爱的人的姓名";
    
    
    //设置输入框是否重新输入时清空内容
    textField.clearsOnBeginEditing = NO;
    
    //设置键盘样式
    textField.keyboardType = UIKeyboardTypeNumberPad;
    
    
    //设置键盘上的return健样式
    textField.returnKeyType = UIReturnKeyDone;
    
    
    [containerView addSubview:textField];
    [textField release];
    
    //设置键盘上的清除按钮模式
    textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    //设置输入框输入的内容是否以密文形式显现
    textField.secureTextEntry = YES;
    UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(100, 250, 200, 40)];
    textField1.borderStyle = UITextBorderStyleRoundedRect;
    textField1.placeholder = @"输入一个最讨厌的人";
    textField1.tag = 101;
    //设置APPDdlegate 为 输入框的 代理对象,让APPDdlegate去执行相应的方法,来处理事件。
//     textField.delegate = self;
     textField1.delegate = self;
     NSLog(@"%@",textField1);
    
    
    
    
    textField.returnKeyType = UIReturnKeySend;
    [containerView addSubview:textField1];
    [textField1 release];

posted on 2016-02-21 08:14  哥依然帅气  阅读(150)  评论(0编辑  收藏  举报

导航