108 lines
3.5 KiB
Objective-C
108 lines
3.5 KiB
Objective-C
//
|
|
// XPNewHomeNavView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by XY on 2023/3/3.
|
|
//
|
|
|
|
#import "XPNewHomeNavView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
|
|
///Tool
|
|
#import "ThemeColor+Home.h"
|
|
#import "XPMacro.h"
|
|
#import "UIImage+Utils.h"
|
|
|
|
@interface XPNewHomeNavView()
|
|
|
|
///排行榜
|
|
@property (nonatomic,strong) UIButton *rankButton;
|
|
///搜索
|
|
@property (nonatomic,strong) UIButton *searchButton;
|
|
|
|
@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.backgroundColor = [UIColor clearColor];
|
|
[self addSubview:self.rankButton];
|
|
[self addSubview:self.searchButton];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
[self.rankButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(30, 30));
|
|
make.right.mas_equalTo(-15);
|
|
make.top.mas_equalTo(kStatusBarHeight+7);
|
|
}];
|
|
|
|
[self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.rankButton);
|
|
make.right.mas_equalTo(self.rankButton.mas_left).offset(-15);
|
|
make.height.mas_equalTo(32);
|
|
make.left.mas_equalTo(15);
|
|
}];
|
|
}
|
|
|
|
|
|
#pragma mark - Event Response
|
|
- (void)searchButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomeNavView:didClickSearch:)]) {
|
|
[self.delegate xPNewHomeNavView:self didClickSearch:sender];
|
|
}
|
|
}
|
|
|
|
- (void)rankButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomeNavView:didClickRank:)]) {
|
|
[self.delegate xPNewHomeNavView:self didClickRank:sender];
|
|
}
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (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;
|
|
}
|
|
|
|
- (UIButton *)searchButton {
|
|
if (!_searchButton) {
|
|
_searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_searchButton setImage:[UIImage imageNamed:@"home_nav_search"] forState:UIControlStateNormal];
|
|
[_searchButton addTarget:self action:@selector(searchButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
_searchButton.layer.masksToBounds = YES;
|
|
_searchButton.layer.cornerRadius = 16;
|
|
[_searchButton setTitle:@"搜索用户ID/房间ID" forState:UIControlStateNormal];
|
|
_searchButton.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
[_searchButton setTitleColor:[ThemeColor colorWithHexString:@"#9EB5C5"] forState:UIControlStateNormal];
|
|
_searchButton.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.5];
|
|
_searchButton.layer.borderColor = UIColor.whiteColor.CGColor;
|
|
_searchButton.layer.borderWidth = 1;
|
|
[_searchButton setImageEdgeInsets:UIEdgeInsetsMake(0, 13, 0, 0)];
|
|
[_searchButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 13, 0, 0)];
|
|
_searchButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
|
|
}
|
|
return _searchButton;
|
|
}
|
|
|
|
@end
|