美文网首页ios实用开发技巧
iOS修改UITextField输入收个字符的位置,以及调整pl

iOS修改UITextField输入收个字符的位置,以及调整pl

作者: 男人宫 | 来源:发表于2017-03-21 16:42 被阅读93次
    _inputTF = [[UITextField alloc] init];
        _inputTF.delegate = self;
        _inputTF.keyboardType = UIKeyboardTypeNumberPad;
        NSMutableParagraphStyle *style = [_inputTF.defaultTextAttributes[NSParagraphStyleAttributeName] mutableCopy];
        
        style.minimumLineHeight = _inputTF.font.lineHeight - (_inputTF.font.lineHeight - [UIFont systemFontOfSize:kScaleNum6(12)].lineHeight) / 2.0;
        _inputTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"充值金额(元)" attributes:@{
                                                                                                            NSForegroundColorAttributeName: [UIColor colorWithRed:183/255.0 green:183/255.0 blue:183/255.0 alpha:1.0],  NSFontAttributeName : [UIFont systemFontOfSize:kScaleNum6(15)],NSParagraphStyleAttributeName : style }];
        [self.scrollerTableV.tableHeaderView addSubview:_inputTF];
        [_inputTF mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(blueView.mas_bottom).offset(kScaleNum6(8));
            make.right.mas_equalTo(-12);
            make.height.mas_equalTo(kScaleNum6(30.5));
            make.width.mas_equalTo(kScaleNum6(120));
        }];
    //输入字符的左边留出空白
        _inputTF.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScaleNum6W(8), kScaleNum6(120))];
        _inputTF.leftViewMode = UITextFieldViewModeAlways;
        _inputTF.layer.borderWidth = 1;
        _inputTF.layer.borderColor = [UIColor grayColor].CGColor;
    

    相关文章

      网友评论

        本文标题:iOS修改UITextField输入收个字符的位置,以及调整pl

        本文链接:https://www.haomeiwen.com/subject/hkygnttx.html