修改placehoder的颜色:
[ self.loginnameText setValue:[UIColor colorWithRed:184.f/255 green:214.f/255 blue:225.f/255 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
[ self.passwordText setValue:[UIColor colorWithRed:184.f/255 green:214.f/255 blue:225.f/255 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
改变键盘类型:
self.loginnameText.returnKeyType = UIReturnKeyNext;
self.passwordText.returnKeyType = UIReturnKeyGo;
给左右两边添加View:
_clearRightButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_clearRightButton setFrame:CGRectMake(0, 0, 20, 20)];
[_clearRightButton setBackgroundImage:[UIImage imageNamed:@"cha"] forState:UIControlStateNormal];
[_clearRightButton addTarget:self action:@selector(clearLoginName) forControlEvents:UIControlEventTouchUpInside];
_clearRightButtonR = [UIButton buttonWithType:UIButtonTypeCustom];
[_clearRightButtonR setFrame:CGRectMake(0, 0, 20, 20)];
[_clearRightButtonR setBackgroundImage:[UIImage imageNamed:@"cha"] forState:UIControlStateNormal];
[_clearRightButtonR addTarget:self action:@selector(clearPassWord) forControlEvents:UIControlEventTouchUpInside];
self.loginnameText.rightView =_clearRightButton;
self.loginnameText.rightViewMode=UITextFieldViewModeWhileEditing;
self.passwordText.rightView =_clearRightButtonR;
self.passwordText.rightViewMode=UITextFieldViewModeWhileEditing;