码迷,mamicode.com
首页 > 其他好文 > 详细

UITextField

时间:2016-04-01 01:14:12      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

 

    //找到已经创建好的UITextField
    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(50, 100, RFSCREEN_W - 100 , 45)];
    textField.leftImageName = @"login_user_icon"
    //设置边框样式
    textField.borderStyle = UITextBorderStyleNone;
    //通过layer设置圆角
    //textField.layer.cornerRadius = 10;
    textField.layer.borderColor = Color_White.CGColor;
    textField.layer.borderWidth = 1;
    // 设置字体颜色
    textField.textColor = Color_White;
    // 输入框中是否有个叉号,在什么时候显示,用于一次性删除输入框中的内容
    textField.clearButtonMode = UITextFieldViewModeAlways;
    //第一响应者,一个界面可能有多个可输入的控件,哪一个正在编辑哪一个就是第一响应者
    [textField becomeFirstResponder];
    // 设置左边图标
    UIImageView *leftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_user_icon"]];
    leftImageView.frame = CGRectMake(0, 0, 50, 50);
    leftImageView.contentMode = UIViewContentModeCenter;
    textField.leftView = leftImageView;
    //设置左视图的显示模式
    textField.leftViewMode = UITextFieldViewModeAlways;
    // 设置键盘的样式
    textField.keyboardType = UIKeyboardTypeNumberPad;
    // 设置占位文字
    textField.placeholder = @"请输入用户名";
    // 设置占位文字的颜色
    [textField setValue:Color_White forKeyPath:@"placeholderLabel.textColor"];
    
    [self.view addSubview:textField];

 

UITextField

标签:

原文地址:http://www.cnblogs.com/jys509/p/5343451.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!