ios - textfield 的rightview 的显示问题
阿神
阿神 2017-04-17 17:27:08
[iOS讨论组]

有如下 代码:
给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;
    }
阿神
阿神

闭关修行中......

全部回复(1)
阿神

此处应该有截图?对比一下没有和有的时候的效果

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号