TextField的属性、操作 相应者

//修改光标的颜色
            textfield.tintColor = [UIColor redColor];
 //添加左侧图片视图
            textfield.leftViewMode = UITextFieldViewModeAlways;
            UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
            imageview.image = [UIImage imageNamed:@"Account"];
            
            textfield.leftView = imageview;
//加前面的间距
-(void)setTextFieldLeftPadding:(UITextField *)textField forWidth:(CGFloat)leftWidth
{
    CGRect frame = textField.frame;
    frame.size.width = leftWidth;
    UIView *leftview = [[UIView alloc] initWithFrame:frame];
    textField.leftViewMode = UITextFieldViewModeAlways;
    textField.leftView = leftview;
}


  TextField的操作

//修改光标的颜色
            textfield.tintColor = [UIColor redColor];

 //添加左侧图片视图
            textfield.leftViewMode = UITextFieldViewModeAlways;
            UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 25, 25)];
            imageview.image = [UIImage imageNamed:@"Account"];
            
            textfield.leftView = imageview;

属性:

secureTextEntry :  安全输入

clearButtonMode : 后面的小叉叉

clearsOnBeginEditing : 点击就清楚里面的东西


borderStyle : 边框样式
//键盘的样式
_search.keyboardType = UIKeyboardTypeEmailAddress;
        _search.returnKeyType = UIReturnKeySearch;


textField的协议(Delegate)   textField为键盘的第一响应者
- (void)textFieldDidBeginEditing:(UITextField *)textField{ }

[self.textview resignFirstResponder];/**< 辞去相应者 */


//实时监控textfeild里面的值
[_iphone addTarget:self action:@selector(valueChanged:)  forControlEvents:UIControlEventAllEditingEvents];





你可能感兴趣的:(TextField的属性、操作 相应者)