// // XPHomePartyNavView.m // xplan-ios // // Created by GreenLand on 2022/9/21. // #import "XPHomePartyNavView.h" #import "ThemeColor.h" #import #import "XPMacro.h" @interface XPHomePartyNavView() @property (nonatomic, strong) UIButton *backBtn; @property (nonatomic, strong) UILabel *titleLabel; @end @implementation XPHomePartyNavView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubViews]; [self initSubViewConstraints]; } return self; } #pragma mark - Private Method - (void)initSubViews { self.backgroundColor = [UIColor clearColor]; [self addSubview:self.titleLabel]; [self addSubview:self.backBtn]; } - (void)initSubViewConstraints { [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self); make.height.mas_equalTo(40); make.top.mas_equalTo(kStatusBarHeight + 2); }]; [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(30, 30)); make.centerY.mas_equalTo(self.titleLabel); make.left.mas_equalTo(16); }]; } #pragma mark - Event Response - (void)backButtonAction:(UIButton *)sender { if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomePartyNavViewDidClickBack)]) { [self.delegate xPHomePartyNavViewDidClickBack]; } } #pragma mark - Getters And Setters - (UILabel *)titleLabel { if(!_titleLabel) { _titleLabel = [[UILabel alloc] init]; _titleLabel.text = @"更多房间"; _titleLabel.font = [UIFont systemFontOfSize:18]; _titleLabel.textColor = [ThemeColor mainTextColor]; } return _titleLabel; } - (UIButton *)backBtn { if (!_backBtn) { _backBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_backBtn setImage:[UIImage imageNamed:@"common_nav_back"] forState:UIControlStateNormal]; [_backBtn addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside]; } return _backBtn; } @end