| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 | ////  ASUserCenterEnterItemV.m//  Asteria////  Created by iOS on 2023/5/16.//#import "ASUserCenterEnterItemV.h"#import "ASEnterItemV.h"@interface ASUserCenterEnterItemV ()@property (nonatomic, strong) UIView *bgV;@property (nonatomic, strong) UIStackView *enterStackV;@property (nonatomic, strong) UIStackView *enterStackV2;@property (nonatomic, strong) NSArray<ASEnterItemV *> *itemsV;@end@implementation ASUserCenterEnterItemV- (instancetype)initWithFrame:(CGRect)frame {    CGRect rect = frame;    rect.size = CGSizeMake(KScreenWidth, 219);    self = [super initWithFrame:rect];    if (self) {        [self createItemsV];        [self configSubV];    }    return self;}- (void)configSubV {    self.backgroundColor = Col_FFF;    [self addSubview:self.bgV];    [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {        make.leading.top.equalTo(self).offset(10);        make.bottom.trailing.equalTo(self).offset(-10);    }];            UIStackView *totalSt = [UIStackView baseStackV:true];    totalSt.distribution = UIStackViewDistributionFillEqually;    totalSt.spacing = 10;    [totalSt addArrangedSubview:self.enterStackV];    [totalSt addArrangedSubview:self.enterStackV2];        [self.bgV addSubview:totalSt];    [totalSt mas_makeConstraints:^(MASConstraintMaker *make) {        make.leading.equalTo(self).offset(15);        make.trailing.equalTo(self).offset(-15);        make.top.equalTo(self).offset(30);        make.bottom.equalTo(self).offset(-30);    }];        for (int i=0; i<self.itemsV.count;i++) {        int a = i/3;        ASEnterItemV *v = self.itemsV[i];        if (a == 0) {            [self.enterStackV addArrangedSubview:v];        } else {            [self.enterStackV2 addArrangedSubview:v];        }    }    }- (UIView *)bgV {    if (!_bgV) {        UIView *v = [UIView baseV];        v.layer.cornerRadius = 8;        v.layer.masksToBounds = true;        v.backgroundColor = _F8F8F8;        _bgV = v;    }    return _bgV;}- (UIStackView *)enterStackV {    if (!_enterStackV) {        UIStackView *v = [[UIStackView alloc] init];        v.axis = UILayoutConstraintAxisHorizontal;        v.spacing = 10;        v.alignment = UIStackViewAlignmentFill;        v.distribution = UIStackViewDistributionFillEqually;        _enterStackV = v;    }    return _enterStackV;}- (UIStackView *)enterStackV2 {    if (!_enterStackV2) {        UIStackView *v = [[UIStackView alloc] init];        v.axis = UILayoutConstraintAxisHorizontal;        v.spacing = 10;        v.alignment = UIStackViewAlignmentFill;        v.distribution = UIStackViewDistributionFillEqually;        _enterStackV2 = v;    }    return _enterStackV2;}- (void)createItemsV {    NSArray *titleArr = @[@"Coupons", @"Gift Card", @"Points" , @"VIP Center",@"Customer Service",@"Message"];    NSArray *iconArr = @[@"uc_coupons", @"uc_giftcard",@"uc_points", @"uc_VIPCenter",@"uc_service",@"uc_message"];    NSMutableArray *tempArr = [NSMutableArray array];    for (int i = 0; i<titleArr.count; i++) {        NSString *tit = titleArr[i];        UIImage *img = [UIImage imageNamed:iconArr[i]];        ASEnterItemV *v = [[ASEnterItemV alloc] initWithFrame:CGRectZero];        [v setData:tit icon:img];        @weakify(self);        [v setClickCallBack:^{            [weak_self tapItemAction:i];        }];        [tempArr addObject:v];    }        self.itemsV = tempArr;}- (void)tapItemAction:(NSInteger)tag {    if (self.itemTapCallBack) {        self.itemTapCallBack(tag);    }}@end
 |