// // LoginInputView.m // xplan-ios // // Created by 冯硕 on 2021/9/8. // #import "LoginInputView.h" ///第三方 #import ///工具类 @interface LoginInputView () ///容器 @property (nonatomic,strong) UIStackView *stackView; ///显示文本 @property (nonatomic,strong) UILabel *titleLabel; ///输入框 @property (nonatomic,strong) UITextField *textField; @end @implementation LoginInputView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubViews]; [self initSubViewConstraints]; } return self; } #pragma mark - Private Method - (void)initSubViews { [self addSubview:self.stackView]; [self.stackView addArrangedSubview:self.titleLabel]; [self.stackView addArrangedSubview:self.textField]; } - (void)initSubViewConstraints { [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(50); }]; [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self).offset(15); make.right.top.bottom.mas_equalTo(self); }]; } #pragma mark - Getters And Setters - (void)setPlaceHolder:(NSString *)placeHolder { _placeHolder = placeHolder; if (_placeHolder) { self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:_placeHolder attributes:@{NSForegroundColorAttributeName: ThemeTextColor, NSFontAttributeName:[UIFont systemFontOfSize:14]}]; } } - (UIStackView *)stackView { if (!_stackView) { _stackView = [[UIStackView alloc] init]; _stackView.axis = UILayoutConstraintAxisHorizontal; _stackView.distribution = UIStackViewDistributionFill; _stackView.alignment = UIStackViewAlignmentCenter; _stackView.spacing = 0; } return _stackView; } - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [[UILabel alloc] init]; _titleLabel.font = [UIFont systemFontOfSize:18]; _titleLabel.textColor = [UIColor whiteColor]; _titleLabel.text = @"+86"; } return _titleLabel; } - (UITextField *)textField { if (!_textField) { _textField = [[UITextField alloc] init]; _textField.textColor = [UIColor whiteColor]; _textField.font = [UIFont systemFontOfSize:18.f]; _textField.borderStyle = UITextBorderStyleNone; _textField.keyboardType = UIKeyboardTypeNumberPad; _textField.tintColor = ThemeBackgroundColor; _textField.backgroundColor = [UIColor clearColor]; } return _textField; } @end