利用UITextField作为输入框,但是有时候ta的光标太靠←(左),影响美观.所以我们需要修改一下ta光标的位置:
1.设置一个空白View.
2.将View设置为UITextField的LeftView.
3.设置_nameTextField.leftViewMode = UITextFieldViewModeAlways;
- (UITextField *)nameTextField {
if (!_nameTextField) {
_nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 20, W, 40)];
_nameTextField.placeholder = @"安阳-韩韩韩";
_nameTextField.font = [UIFont systemFontOfSize:14.0];
_nameTextField.layer.borderWidth = 1.0;
_nameTextField.layer.borderColor = kMainBGColor.CGColor;
_nameTextField.textColor = kMainTextColor;
//移动光标的方法
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 40)];
_nameTextField.leftView = view;
_nameTextField.leftViewMode = UITextFieldViewModeAlways;
}
return _nameTextField;
}