更换项目
This commit is contained in:
152
YuMi/Modules/YMNewHome/View/CustomView/XPNewHomeNavView.m
Normal file
152
YuMi/Modules/YMNewHome/View/CustomView/XPNewHomeNavView.m
Normal file
@@ -0,0 +1,152 @@
|
||||
//
|
||||
// XPNewHomeNavView.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by YuMi on 2022/10/8.
|
||||
//
|
||||
|
||||
#import "XPNewHomeNavView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "DJDKMIMOMColor.h"
|
||||
#import "YUMIMacroUitls.h"
|
||||
|
||||
|
||||
@interface XPNewHomeNavView ()
|
||||
@property (nonatomic,strong) UIView *searchView;
|
||||
@property (nonatomic,strong) UIImageView *searchImageView;
|
||||
@property (nonatomic,strong) UILabel *searchLabel;
|
||||
@property (nonatomic,strong) UIButton *rankButton;
|
||||
@property (nonatomic,strong) UIButton *opeRoomButton;
|
||||
@end
|
||||
|
||||
@implementation XPNewHomeNavView
|
||||
|
||||
|
||||
- (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.searchView];
|
||||
[self addSubview:self.opeRoomButton];
|
||||
[self addSubview:self.rankButton];
|
||||
|
||||
[self.searchView addSubview:self.searchImageView];
|
||||
[self.searchView addSubview:self.searchLabel];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
|
||||
[self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self).offset(15);
|
||||
make.height.mas_equalTo(32);
|
||||
make.top.mas_equalTo(self).offset(statusbarHeight + 6);
|
||||
make.right.mas_equalTo(self.opeRoomButton.mas_left).offset(-36);
|
||||
}];
|
||||
|
||||
[self.searchImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(22);
|
||||
make.height.mas_equalTo(22);
|
||||
make.left.mas_equalTo(self.searchView).offset(13);
|
||||
make.centerY.mas_equalTo(self.searchView);
|
||||
}];
|
||||
|
||||
[self.searchLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.searchImageView.mas_right).offset(2);
|
||||
make.centerY.mas_equalTo(self.searchView);
|
||||
}];
|
||||
|
||||
[self.rankButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(30);
|
||||
make.height.mas_equalTo(30);
|
||||
make.centerY.mas_equalTo(self.searchView);
|
||||
make.right.mas_equalTo(self).offset(-15);
|
||||
}];
|
||||
|
||||
[self.opeRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.centerY.mas_equalTo(self.rankButton);
|
||||
make.right.mas_equalTo(self.rankButton.mas_left).offset(-12);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)openRoomButtonAction:(UIButton *)sender {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomeNavView:didClickOpenRoom:)]) {
|
||||
[self.delegate xPNewHomeNavView:self didClickOpenRoom:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)rankButtonAction:(UIButton *)sender {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomeNavView:didClickRank:)]) {
|
||||
[self.delegate xPNewHomeNavView:self didClickRank:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tapRecognizer {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomeNavView:didClickSearch:)]) {
|
||||
[self.delegate xPNewHomeNavView:self didClickSearch:self.searchView];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIView *)searchView {
|
||||
if (!_searchView) {
|
||||
_searchView = [[UIView alloc] init];
|
||||
_searchView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5];
|
||||
_searchView.layer.cornerRadius = 16;
|
||||
_searchView.layer.masksToBounds = YES;
|
||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognizer)];
|
||||
[_searchView addGestureRecognizer:tap];
|
||||
}
|
||||
return _searchView;
|
||||
}
|
||||
|
||||
- (UIImageView *)searchImageView {
|
||||
if (!_searchImageView) {
|
||||
_searchImageView = [[UIImageView alloc] init];
|
||||
_searchImageView.userInteractionEnabled = YES;
|
||||
_searchImageView.image = [UIImage imageNamed:@"home_nav_search"];
|
||||
}
|
||||
return _searchImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)searchLabel {
|
||||
if (!_searchLabel) {
|
||||
_searchLabel = [[UILabel alloc] init];
|
||||
_searchLabel.font = [UIFont systemFontOfSize:12];
|
||||
_searchLabel.textColor = [DJDKMIMOMColor secondTextColor];
|
||||
_searchLabel.text = YMLocalizedString(@"XPNewHomeNavView0");
|
||||
}
|
||||
return _searchLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)opeRoomButton {
|
||||
if (!_opeRoomButton) {
|
||||
_opeRoomButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_opeRoomButton setImage:[UIImage imageNamed:@"home_nav_open_room"] forState:UIControlStateNormal];
|
||||
[_opeRoomButton setImage:[UIImage imageNamed:@"home_nav_open_room"] forState:UIControlStateSelected];
|
||||
[_opeRoomButton addTarget:self action:@selector(openRoomButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _opeRoomButton;
|
||||
}
|
||||
|
||||
- (UIButton *)rankButton {
|
||||
if (!_rankButton) {
|
||||
_rankButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_rankButton setImage:[UIImage imageNamed:@"home_nav_rank"] forState:UIControlStateNormal];
|
||||
[_rankButton setImage:[UIImage imageNamed:@"home_nav_rank"] forState:UIControlStateSelected];
|
||||
[_rankButton addTarget:self action:@selector(rankButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _rankButton;
|
||||
}
|
||||
|
||||
|
||||
@end
|
Reference in New Issue
Block a user