//
|
// RecommendNavView.m
|
// BuWanVideo2.0
|
//
|
// Created by Aeline on 2021/5/23.
|
// Copyright © 2021 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "RecommendNavView.h"
|
|
@interface RecommendNavView ()
|
|
@property (nonatomic, strong) UIView *viewNav;
|
@property (nonatomic, strong) UIView *viewSearch;
|
|
@end
|
|
@implementation RecommendNavView
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
self = [super initWithFrame:frame];
|
if (self) {
|
[self setupViewConfig];
|
}
|
return self;
|
}
|
|
- (void)setupViewConfig {
|
[self addSubview:self.viewNav];
|
self.viewNav.sd_layout.topSpaceToView(self, kStatusBarH).leftEqualToView(self).rightEqualToView(self).heightIs(44);
|
|
//UIButton *buttonMore = [[UIButton alloc] init];
|
//[buttonMore setImage:[UIImage imageNamed:@"home_more"] forState:UIControlStateNormal];
|
//[self addSubview:buttonMore];
|
//buttonMore.sd_layout.rightSpaceToView(self, 18).centerYEqualToView(_viewNav).widthIs(21).heightIs(24);
|
|
UIButton *buttonRecord = [[UIButton alloc] init];
|
[buttonRecord setImage:[UIImage imageNamed:@"home_record"] forState:UIControlStateNormal];
|
[self addSubview:buttonRecord];
|
buttonRecord.sd_layout.rightSpaceToView(self, 51).centerYEqualToView(_viewNav).widthIs(23).heightIs(23);
|
[buttonRecord addTarget:self action:@selector(onViewRecord) forControlEvents:UIControlEventTouchUpInside];
|
|
//分类
|
UIButton *buttonCategory = [[UIButton alloc] init];
|
[buttonCategory setImage:[UIImage imageNamed:@"home_category"] forState:UIControlStateNormal];
|
[self addSubview:buttonCategory];
|
buttonCategory.sd_layout.rightSpaceToView(self, 10).centerYEqualToView(buttonRecord).widthIs(23).heightIs(23);
|
[buttonCategory addTarget:self action:@selector(onViewCategory) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[self.viewNav addSubview:self.viewSearch];
|
self.viewSearch.sd_layout.leftSpaceToView(self.viewNav, 11).centerYEqualToView(self.viewNav).rightSpaceToView(buttonRecord, 21).heightIs(34);
|
self.viewSearch.sd_cornerRadius = @17;
|
|
UIImageView *imageViewSearch = [[UIImageView alloc] init];
|
imageViewSearch.image = [UIImage imageNamed:@"home_search"];
|
[_viewSearch addSubview:imageViewSearch];
|
imageViewSearch.sd_layout.leftSpaceToView(_viewSearch, 13).centerYEqualToView(_viewSearch).widthIs(19).heightIs(19);
|
|
UILabel *label = [[UILabel alloc] init];
|
label.font = [UIFont systemFontOfSize:14];
|
label.textAlignment = NSTextAlignmentLeft;
|
label.textColor = UICOLOR_FROM_RGB(0x787878, 1);
|
[_viewSearch addSubview:label];
|
label.sd_layout.leftSpaceToView(imageViewSearch, 13).centerYEqualToView(_viewSearch).heightIs(20).rightSpaceToView(_viewSearch, 0);
|
}
|
|
- (void)onViewRecord {
|
!self.onRecord?:self.onRecord();
|
}
|
|
- (void)onViewCategory {
|
!self.onCategory?:self.onCategory();
|
}
|
|
- (void)touchSearch {
|
!self.onSearch?:self.onSearch();
|
}
|
|
- (void)setTitle:(NSString *)title {
|
_title = title;
|
if (title) {
|
UILabel *label = [self.viewSearch subviews][1];
|
label.text = title;
|
}
|
}
|
|
- (UIView *)viewNav {
|
if (!_viewNav) {
|
_viewNav = [[UIView alloc] init];
|
}
|
return _viewNav;
|
}
|
|
- (UIView *)viewSearch {
|
if (!_viewSearch) {
|
_viewSearch = [[UIView alloc] init];
|
_viewSearch.backgroundColor = UICOLOR_FROM_RGB(0xEBEBEB, 1);
|
_viewSearch.userInteractionEnabled = YES;
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchSearch)];
|
[_viewSearch addGestureRecognizer:tap];
|
}
|
return _viewSearch;
|
}
|
@end
|