Files
yinmeng-ios/xplan-ios/Main/Home/View/Mew/MewHomeView/MewHomeSubViews/MewMainHomeNavView.m
2023-12-21 18:42:16 +08:00

121 lines
4.4 KiB
Objective-C

//
// MewMainNavView.m
// xplan-ios
//
// Created by duoban on 2023/12/20.
//
#import "MewMainHomeNavView.h"
@interface MewMainHomeNavView()
///搜索
@property(nonatomic,strong) UIView *mewBgSearchView;
@property(nonatomic,strong) UIImageView *mewSearchIconView;
@property(nonatomic,strong) UILabel *mewSearchTextView;
///我的房间
@property(nonatomic,strong) UIButton *mewRoomBtn;
///榜单
@property(nonatomic,strong) UIButton *mewRankBnt;
@end
@implementation MewMainHomeNavView
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self installUI];
[self installConstraints];
}
return self;
}
-(void)installUI{
[self addSubview:self.mewBgSearchView];
[self addSubview:self.mewRoomBtn];
[self addSubview:self.mewRankBnt];
[self.mewBgSearchView addSubview:self.mewSearchIconView];
[self.mewBgSearchView addSubview:self.mewSearchTextView];
}
-(void)installConstraints{
[self.mewBgSearchView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.leading.equalTo(self);
make.height.mas_equalTo(26);
make.width.mas_equalTo(136);
}];
[self.mewRoomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(30);
make.leading.equalTo(self.mewBgSearchView.mas_trailing).mas_offset(8);
make.centerY.equalTo(self);
}];
[self.mewRankBnt mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(30);
make.leading.equalTo(self.mewRoomBtn.mas_trailing).mas_offset(8);
make.centerY.equalTo(self);
}];
[self.mewSearchIconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(16);
make.leading.mas_equalTo(9);
make.centerY.equalTo(self.mewBgSearchView);
}];
[self.mewSearchTextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(32);
make.trailing.mas_equalTo(-5);
make.centerY.equalTo(self.mewBgSearchView);
}];
}
-(void)clickSearchViewAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(mew_MainHomeNavView:didClickSearch:)]){
[self.delegate mew_MainHomeNavView:self didClickSearch:self.mewBgSearchView];
}
}
-(void)clickRoomAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(mew_MainHomeNavView:didClickRoom:)]){
[self.delegate mew_MainHomeNavView:self didClickRoom:self.mewRoomBtn];
}
}
-(void)clickRankAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(mew_MainHomeNavView:didClickRank:)]){
[self.delegate mew_MainHomeNavView:self didClickRank:self.mewRankBnt];
}
}
#pragma mark - 懒加载
- (UIView *)mewBgSearchView{
if(!_mewBgSearchView){
_mewBgSearchView = [UIView new];
_mewBgSearchView.backgroundColor = [UIColor whiteColor];
_mewBgSearchView.layer.cornerRadius = kGetScaleWidth(26)/2;
_mewBgSearchView.layer.masksToBounds = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickSearchViewAction)];
[_mewBgSearchView addGestureRecognizer:tap];
}
return _mewBgSearchView;
}
-(UIImageView *)mewSearchIconView{
if(!_mewSearchIconView){
_mewSearchIconView = [UIImageView new];
_mewSearchIconView.image = kImage(@"mew_home_nav_search_icon");
}
return _mewSearchIconView;
}
- (UILabel *)mewSearchTextView{
if(!_mewSearchTextView){
_mewSearchTextView = [UILabel labelInitWithText:@"搜索ID、房间" font:[UIFont systemFontOfSize:12 weight:UIFontWeightRegular] textColor:UIColorFromRGB(0xB8B7C7)];
}
return _mewSearchTextView;
}
- (UIButton *)mewRoomBtn{
if(!_mewRoomBtn){
_mewRoomBtn = [UIButton new];
[_mewRoomBtn setBackgroundImage:kImage(@"mew_home_nav_click_room") forState:UIControlStateNormal];
[_mewRoomBtn addTarget:self action:@selector(clickRoomAction) forControlEvents:UIControlEventTouchUpInside];
}
return _mewRoomBtn;
}
- (UIButton *)mewRankBnt{
if(!_mewRankBnt){
_mewRankBnt = [UIButton new];
[_mewRankBnt setBackgroundImage:kImage(@"mew_home_nav_click_rank") forState:UIControlStateNormal];
[_mewRankBnt addTarget:self action:@selector(clickRankAction) forControlEvents:UIControlEventTouchUpInside];
}
return _mewRankBnt;
}
@end