// // KBSettingView.m // CustomKeyboard // #import "KBSettingView.h" #import "Masonry.h" @interface KBSettingView () @property (nonatomic, strong) UIButton *backButtonInternal; @property (nonatomic, strong) UILabel *titleLabel; @end @implementation KBSettingView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // 背景做成淡色,和主界面区分 self.backgroundColor = [UIColor colorWithWhite:1 alpha:0.96]; [self addSubview:self.backButtonInternal]; [self.backButtonInternal mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.mas_left).offset(10); make.top.equalTo(self.mas_top).offset(8); make.width.height.mas_equalTo(32); }]; self.titleLabel = [[UILabel alloc] init]; self.titleLabel.text = KBLocalized(@"设置"); self.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; self.titleLabel.textColor = [UIColor blackColor]; [self addSubview:self.titleLabel]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.backButtonInternal.mas_centerY); make.centerX.equalTo(self.mas_centerX); }]; // 占位内容 UILabel *place = [[UILabel alloc] init]; place.text = KBLocalized(@"这里是设置内容占位"); place.textColor = [UIColor darkGrayColor]; place.font = [UIFont systemFontOfSize:14]; [self addSubview:place]; [place mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self); }]; } return self; } #pragma mark - Lazy - (UIButton *)backButtonInternal { if (!_backButtonInternal) { _backButtonInternal = [UIButton buttonWithType:UIButtonTypeSystem]; _backButtonInternal.layer.cornerRadius = 16; _backButtonInternal.layer.masksToBounds = YES; _backButtonInternal.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.0]; [_backButtonInternal setTitle:@"←" forState:UIControlStateNormal]; // 返回箭头 [_backButtonInternal setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; _backButtonInternal.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; } return _backButtonInternal; } #pragma mark - Expose - (UIButton *)backButton { return self.backButtonInternal; } @end