2023-12-21 18:42:16 +08:00
|
|
|
//
|
|
|
|
// MewMainHomePartyHeadItemView.m
|
|
|
|
// xplan-ios
|
|
|
|
//
|
|
|
|
// Created by duoban on 2023/12/20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MewMainHomePartyHeadItemView.h"
|
|
|
|
@interface MewMainHomePartyHeadItemView()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@implementation MewMainHomePartyHeadItemView
|
|
|
|
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if(self){
|
|
|
|
[self installUI];
|
|
|
|
[self installConstraints];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
-(void)installUI{
|
|
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
NetImageConfig *config = [[NetImageConfig alloc]init];
|
|
|
|
config.placeHolder = [UIImageConstant defalutBannerPlaceholder];
|
|
|
|
NetImageView *imageView = [[NetImageView alloc]initWithConfig:config];
|
2023-12-26 14:29:53 +08:00
|
|
|
imageView.backgroundColor = [UIColor clearColor];
|
2023-12-21 18:42:16 +08:00
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickBtnAction:)];
|
|
|
|
[imageView addGestureRecognizer:tap];
|
|
|
|
imageView.userInteractionEnabled = YES;
|
|
|
|
imageView.tag = i + 100;
|
|
|
|
imageView.hidden = YES;
|
|
|
|
if(i == 4){
|
|
|
|
imageView.hidden = NO;
|
|
|
|
imageView.image = kImage(@"mew_home_party_head_morn");
|
|
|
|
}
|
|
|
|
[self addSubview:imageView];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-(void)clickBtnAction:(UITapGestureRecognizer *)sender{
|
|
|
|
NetImageView *imageView = (NetImageView *)sender.view;
|
|
|
|
NSInteger index = imageView.tag - 100;
|
|
|
|
MewMainHomeMenuInfoModel *obj;
|
|
|
|
if(index == 4){
|
|
|
|
obj = [MewMainHomeMenuInfoModel new];
|
|
|
|
obj.isMorn = YES;
|
|
|
|
}else{
|
|
|
|
obj = [_mewMenuList safeObjectAtIndex1:index];
|
|
|
|
}
|
|
|
|
if(obj && self.delegate && [self.delegate respondsToSelector:@selector(mew_clickMainHomeHeadItemViewMenu:)]){
|
|
|
|
[self.delegate mew_clickMainHomeHeadItemViewMenu:obj];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-(void)installConstraints{
|
|
|
|
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
|
|
|
|
NetImageView *imageView = [self viewWithTag:100 + i];
|
|
|
|
if(i == 0){
|
|
|
|
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(kGetScaleWidth(0));
|
|
|
|
make.leading.mas_equalTo(kGetScaleWidth(15));
|
|
|
|
make.width.mas_equalTo(kGetScaleWidth(171));
|
|
|
|
make.height.mas_equalTo(kGetScaleWidth(88));
|
|
|
|
}];
|
|
|
|
}else if(i == 1){
|
|
|
|
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(kGetScaleWidth(0));
|
|
|
|
make.trailing.mas_equalTo(-kGetScaleWidth(15));
|
|
|
|
make.width.mas_equalTo(kGetScaleWidth(171));
|
|
|
|
make.height.mas_equalTo(kGetScaleWidth(88));
|
|
|
|
}];
|
|
|
|
}else if(i == 2){
|
|
|
|
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(kGetScaleWidth(95));
|
|
|
|
make.leading.mas_equalTo(kGetScaleWidth(15));
|
|
|
|
make.width.mas_equalTo(kGetScaleWidth(113));
|
|
|
|
make.height.mas_equalTo(kGetScaleWidth(48));
|
|
|
|
}];
|
|
|
|
}else if(i == 3){
|
|
|
|
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(kGetScaleWidth(95));
|
|
|
|
make.centerX.equalTo(self);
|
|
|
|
make.width.mas_equalTo(kGetScaleWidth(113));
|
|
|
|
make.height.mas_equalTo(kGetScaleWidth(48));
|
|
|
|
}];
|
|
|
|
}else{
|
|
|
|
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.mas_equalTo(kGetScaleWidth(95));
|
|
|
|
make.trailing.mas_equalTo(-kGetScaleWidth(15));
|
|
|
|
make.width.mas_equalTo(kGetScaleWidth(113));
|
|
|
|
make.height.mas_equalTo(kGetScaleWidth(48));
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
-(void)setMewMenuList:(NSArray *)mewMenuList{
|
|
|
|
_mewMenuList = mewMenuList;
|
|
|
|
if(_mewMenuList.count == 0){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
NetImageView *imageView = [self viewWithTag:100 + i];
|
|
|
|
imageView.hidden = YES;
|
|
|
|
MewMainHomeMenuInfoModel *obj = [_mewMenuList safeObjectAtIndex1:i];
|
|
|
|
if(obj != nil){
|
|
|
|
if(obj.posSeq == i+1){
|
|
|
|
imageView.hidden = NO;
|
|
|
|
imageView.imageUrl = obj.icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#pragma mark - 懒加载
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|