ios实用开发技巧

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

2017-03-21  本文已影响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;
上一篇下一篇

猜你喜欢

热点阅读