13

-(instancetype)initWithFrame:(CGRect)frame {

    self = [super initWithFrame:frame];

    if (self) {

        //获取整体宽高

        CGFloat totalWidth = frame.size.width;

        CGFloat totalHeight = frame.size.height;

        

        //确定内部空间的宽高

        CGFloat labelWidth = (totalWidth - 15) / 3;

        CGFloat labelHeight = (totalHeight -4);

        

        CGFloat textFieldWidth = 2 * labelWidth;

        CGFloat textFieldHeight = labelHeight;

        

        _label = [[UILabel alloc] initWithFrame:CGRectMake(5, 2, labelWidth, labelHeight)];

        [self addSubview:_label];

        

        _textField = [[UITextField alloc] initWithFrame:CGRectMake(labelWidth + 10, 2, textFieldWidth, textFieldHeight)];

        _textField.borderStyle = UITextBorderStyleRoundedRect;

        [self addSubview:_textField];

        

        

    }

    return self;

}

 

 

- (instancetype)initWithFrame:(CGRect)frame text:(NSString *)text placeholder:(NSString *)placeholder secureTextEntry:(BOOL)secureTextEntry keyboardStyle:(UIKeyboardType)keyboardStyle {

    self = [super initWithFrame:frame];

    if (self) {

        self.label.text = text;

        self.textField.placeholder = placeholder;

        self.textField.secureTextEntry = secureTextEntry;

        self.textField.keyboardType = keyboardStyle;

    }

    

    return  self;

    

}

 

posted @ 2016-02-23 09:14  whwhll  阅读(135)  评论(0)    收藏  举报