123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- //
- // ASProductListMenuHeaderView.m
- // Asteria
- //
- // Created by iOS on 2023/6/12.
- //
- #import "ASProductListMenuHeaderView.h"
- @interface ASProductListMenuHeaderView ()
- @property (nonatomic, strong) UIView *sortMenuV;
- @property (nonatomic, strong) UIButton *menuBt;
- @property (nonatomic, copy) btnClickBlock menuBlock;
- @property (nonatomic, copy) btnClickBlock sortBlock;
- @end
- @implementation ASProductListMenuHeaderView
- - (void)setData:(NSString *)sortTitle sortBlock:(btnClickBlock)sortBlock menuBlock:(btnClickBlock)menuBlock {
- [self.sortBt setTitle:sortTitle forState:UIControlStateNormal];
- self.sortBlock = sortBlock;
- self.menuBlock = menuBlock;
- }
- - (void)sortBtAction {
- if (self.sortBlock) {
- self.sortBlock();
- }
- }
- - (void)menuBtAction {
- if (self.menuBlock) {
- self.menuBlock();
- }
- }
- // MARK: - init
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
- [self loadV];
- }
- return self;
- }
- - (void)loadV {
- self.sortMenuV.frame = CGRectMake(0, 0, KScreenWidth, 60);
- [self.sortBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(self.sortMenuV).offset(15);
- make.height.equalTo(@22);
- make.centerY.equalTo(self.sortMenuV);
- }];
- [self.menuBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.trailing.equalTo(self.sortMenuV).offset(-15);
- make.width.height.equalTo(@34);
- make.centerY.equalTo(self.sortMenuV);
- make.leading.greaterThanOrEqualTo(self.sortBt.mas_trailing).offset(10);
- }];
- [self addSubview:self.sortMenuV];
- [self.sortMenuV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self);
- make.height.equalTo(@60);
- }];
- }
- - (UIView *)sortMenuV {
- if (!_sortMenuV) {
- UIView *v = [UIView baseV];
- v.backgroundColor = _F5F5F5;
- UIButton *sortBt = [UIButton buttonWithType:UIButtonTypeCustom];
- [sortBt setTitle:@"SORT BY" forState:UIControlStateNormal];
- [sortBt setTitleColor:Col_000 forState:UIControlStateNormal];
- sortBt.titleLabel.font = [UIFont fontWithName:Rob_Bold size:14];
- [sortBt addTarget:self action:@selector(sortBtAction) forControlEvents:UIControlEventTouchUpInside];
- self.sortBt = sortBt;
- UIButton *nBt = [UIButton buttonWithType:UIButtonTypeCustom];
- [nBt setImage:[UIImage imageNamed:@"productList_menu"] forState:UIControlStateNormal];
- [nBt addTarget:self action:@selector(menuBtAction) forControlEvents:UIControlEventTouchUpInside];
- self.menuBt = nBt;
- [v addSubview:self.sortBt];
- [v addSubview:self.menuBt];
- _sortMenuV = v;
- }
- return _sortMenuV;
- }
- @end
|