有如下 代码:
给textfield设置了一个rightview
然后设置了 field.rightViewMode = UITextFieldViewModeAlways;
为什么还是只有当这个field成为firsetresponder的时候这个rightview 才回显示出来?
求大虾解答
{
button *button = [[button alloc] init];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize:11];
button.layer.cornerRadius = 5.f;
button.layer.masksToBounds = YES;
[button addTarget:self action:@selector(acquireButtonClick) forControlEvents:UIControlEventTouchUpInside];
self.acquireButton = button;
if (_seconds > 0) {
[_acquireButton setTitle:[NSString stringWithFormat:@"%@秒后重试",@(_seconds)] forState:UIControlStateDisabled];
_acquireButton.enabled = NO;
[self validTimer];
} else {
_acquireButton.enabled = YES;
[button setTitle:@"获取验证码" forState:UIControlStateNormal];
[self invalidTimer];
}
}
{
UITextField *field = [[UITextField alloc] init];
field.placeholder = @"请输入验证码";
field.backgroundColor = [UIColor clearColor];
field.borderStyle = UITextBorderStyleNone;
field.font = [UIFont systemFontOfSize:14];
field.textColor = [UIColor appGray150Color];
field.rightView = _acquireButton;
field.rightViewMode = UITextFieldViewModeAlways;
[self addSubview:field];
self.codeFieled = field;
}
此处应该有截图?对比一下没有和有的时候的效果