您的位置:首页 > 产品设计 > UI/UE

UITextfield的一些属性

2016-04-06 20:28 477 查看
//设置左视图 不用设置frame

UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"phoneIcon@x"]];

self.infoText.leftView = imageV;

self.infoText.leftViewMode = UITextFieldViewModeAlways;

//如果是button带点击事件 不设置frame 视图不能上显示

self.secureBtn = [UIButton buttonWithType:UIButtonTypeSystem];

self.secureBtn.frame = CGRectMake(0, 0, self.pwdText.width / 8, self.pwdText.height);

[self.secureBtn setBackgroundImage:[UIImage imageNamed:@"btn_password_hidden@3x"] forState:UIControlStateNormal];

[self.secureBtn addTarget:self action:@selector(hiden) forControlEvents:UIControlEventTouchUpInside];

self.pwdText.rightView = self.secureBtn;

self.pwdText.rightViewMode = UITextFieldViewModeAlways;

//设置占位符 颜色默认

self.pwdText.Placeholder = @"请输入密码";

//设置占位符的颜色

self.pwdText.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入密码" attributes:

//设置是否是一次性清除按钮

self.infoText.clearButtonMode = YES;//设置

//设置是否隐藏密码

self.pwdText.secureTextEntry = YES ;//隐藏
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: