| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 | ////  ASHomeBannerCell.m//  Asteria////  Created by iOS on 2023/6/5.//#import "ASHomeBannerCell.h"#import "WMZBannerView.h"@interface ASHomeBannerCell ()@property (nonatomic,strong) UIPageControl *control;@property (nonatomic, strong) WMZBannerView *bannerV;@end@implementation ASHomeBannerCell- (void)showData:(NSArray <ASJumpModel*>*)arr {    self.control.numberOfPages = arr.count;    self.control.currentPage = 0;        NSMutableArray *images = [NSMutableArray array];    for (ASJumpModel *m in arr) {        [images addObject:m.image];    }    @weakify(self);    CGFloat h = (KScreenWidth-10-30)/335*445;    WMZBannerParam *param = BannerParam()    .wFrameSet(CGRectMake(-20,10, KScreenWidth+20, h))    .wItemSizeSet(CGSizeMake((KScreenWidth-10-30),h))    .wDataSet(images)    .wPlaceholderImageSet(@"product_defualtImg")    .wScaleFactorSet(0.1f)    .wImageFillSet(false)    .wCustomImageRadioSet(8)    .wEventClickSet(^(id anyID,NSInteger index) {        if (arr.count <= index) {            return;        }        ASJumpModel *temp = arr[index];        weak_self.selectCallBack(index, temp.title, temp.link, temp);    })    .wEventScrollEndSet(^(id anyID, NSInteger index, BOOL isCenter, UICollectionViewCell *cell) {//            NSLog(@"滚动到第%ld个,内容:%@",index,anyID);//        [self.control setCurrentPage:index];    })    .wEventDidScrollSet(^(CGPoint offset){        [weak_self.control setCurrentPage:self.bannerV.bannerControl.currentPage];    })    .wSectionInsetSet(UIEdgeInsetsMake(0, 0, 7, 0))    .wHideBannerControlSet(true)    .wScaleSet(true)    //设置item的间距    .wLineSpacingSet(10)    //开启卡片叠加模式//    .wCardOverLapSet(true)    //毛玻璃背景//    .wEffectSet(YES)    //循环    .wRepeatSet(true)    //开启自动滚动    .wAutoScrollSet(YES)    ;    [self.bannerV resetParam:param];}- (void)awakeFromNib {    [super awakeFromNib];    // Initialization code}- (void)setSelected:(BOOL)selected animated:(BOOL)animated {    [super setSelected:selected animated:animated];    // Configure the view for the selected state}-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];    if (self) {        self.selectionStyle = UITableViewCellSelectionStyleNone;        [self loadSubV];    }    return self;}- (void)loadSubV {    self.backgroundColor = UIColor.whiteColor;        [self.contentView addSubview:self.bannerV];    [self.contentView addSubview:self.control];        CGFloat h = (KScreenWidth-10-30)/335*445;        [self.bannerV mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.equalTo(self.contentView.mas_top).offset(10);        make.left.equalTo(self.contentView).offset(-20);        make.right.equalTo(self.contentView).offset(0);        make.height.equalTo([NSNumber numberWithFloat:h]);    }];        [self.control mas_makeConstraints:^(MASConstraintMaker *make) {        make.top.equalTo(self.bannerV.mas_bottom).offset(10);        make.width.equalTo(@280);        make.height.equalTo(@10);        make.centerX.equalTo(self.contentView);        make.bottom.equalTo(self.contentView).offset(-5);    }];    }// MARK: - subvs-(WMZBannerView *)bannerV {    if (!_bannerV) {        WMZBannerView *v = [[WMZBannerView alloc] init];        _bannerV = v;    }    return _bannerV;}-(UIPageControl *)control {    if (!_control) {        _control = [[UIPageControl alloc] init];        [_control setTintColor:[UIColor colorWithHexString:@"#000000"]];        [_control setPageIndicatorTintColor:[[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.3] ];        [_control setCurrentPageIndicatorTintColor:[UIColor colorWithHexString:@"#000000"] ];        _control.transform = CGAffineTransformScale(_control.transform, 1.15, 1.15);    }    return  _control;}@end
 |