// // NavigationBarView.m // BuguLive // // Created by qitewei on 2025/8/13. // Copyright © 2025 xfg. All rights reserved. // #import "NavigationBarView.h" @implementation NavigationBarView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setupUI]; } return self; } - (void)setupUI { self.backgroundColor = UIColor.whiteColor; [self addSubview:self.contentView]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.backButton]; [self.contentView addSubview:self.rightButton]; [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_offset(STATUS_BAR_HEIGHT); make.left.right.bottom.mas_offset(0); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_offset(0); }]; [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(32); make.left.mas_offset(16); make.centerY.mas_offset(0); }]; [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(32); make.right.mas_offset(-16); make.centerY.mas_offset(0); }]; } - (void)onBackButtonClick { if (self.onBackButtonkAction) { self.onBackButtonkAction(); } } - (void)onRightButtonClick { if (self.onRightButtonkAction) { self.onRightButtonkAction(); } } - (UIView *)contentView { if (!_contentView) { _contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)]; _contentView.backgroundColor = UIColor.whiteColor; } return _contentView; } - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [[UILabel alloc] init]; _titleLabel.textColor = UIColor.blackColor; _titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; } return _titleLabel; } - (UIButton *)backButton { if (!_backButton) { _backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_backButton setImage:[UIImage imageNamed:@"icon_nav_back"] forState:UIControlStateNormal]; [_backButton addTarget:self action:@selector(onBackButtonClick) forControlEvents:UIControlEventTouchUpInside]; } return _backButton; } - (UIButton *)rightButton { if (!_rightButton) { _rightButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_rightButton setImage:[UIImage imageNamed:@"icon_nav_help"] forState:UIControlStateNormal]; [_rightButton addTarget:self action:@selector(onRightButtonClick) forControlEvents:UIControlEventTouchUpInside]; } return _rightButton; } @end