Files
peko-ios/YuMi/Modules/YMMine/View/Recharge/XPIAPRechargeHeadCell.m
eggmanQQQ 627748d230 #916
save code
2024-06-21 01:37:38 +08:00

76 lines
2.8 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// XPIAPRechargeHeadCell.m
// YuMi
//
// Created by duoban on 2023/9/11.
//
#import "XPIAPRechargeHeadCell.h"
#import <SDCycleScrollView/SDCycleScrollView.h>
@interface XPIAPRechargeHeadCell()<SDCycleScrollViewDelegate>
///轮播图
@property (nonatomic, strong) SDCycleScrollView *pi_BannerView;
@end
@implementation XPIAPRechargeHeadCell
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self installUI];
[self installConstraints];
}
return self;
}
-(void)installUI{
[self.contentView addSubview:self.pi_BannerView];
}
-(void)installConstraints{
[self.pi_BannerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self.contentView).inset(kGetScaleWidth(16));
make.top.mas_equalTo(kGetScaleWidth(0));
make.height.mas_equalTo(kGetScaleWidth(94));
}];
}
- (void)setBannerList:(NSArray *)bannerList{
_bannerList = bannerList;
NSMutableArray *list = [NSMutableArray array];
for ( RechargeListModel *rechargeModel in _bannerList) {
[list addObject:rechargeModel.bannerUrl];
}
self.pi_BannerView.imageURLStringsGroup = list;
[self.pi_BannerView autoScroll];
}
#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
if(self.delegate && [self.delegate respondsToSelector:@selector(xpIAPRechargeHeadCell:didSelectItemAtIndex:)]){
[self.delegate xpIAPRechargeHeadCell:self didSelectItemAtIndex:index];
}
}
#pragma mark - 懒加载
- (SDCycleScrollView *)pi_BannerView {
if (!_pi_BannerView) {
_pi_BannerView = [[SDCycleScrollView alloc] init];
_pi_BannerView.backgroundColor = [UIColor clearColor];
_pi_BannerView.layer.cornerRadius = kGetScaleWidth(10);
_pi_BannerView.layer.masksToBounds = YES;
_pi_BannerView.delegate = self;
_pi_BannerView.showPageControl = YES;
_pi_BannerView.autoScrollTimeInterval = 5.0;
_pi_BannerView.currentPageDotColor = UIColorFromRGB(0x9168FA);
_pi_BannerView.pageDotColor = UIColorRGBAlpha(0xB3B3C3, 0.4);
_pi_BannerView.pageControlDotSize = CGSizeMake(kGetScaleWidth(4), kGetScaleWidth(4));
_pi_BannerView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
_pi_BannerView.placeholderImage = [UIImageConstant defaultBannerPlaceholder];
// SDCycleScrollView没有适配阿语在RTL下会乱滚都用LTR算了
_pi_BannerView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
for (UIView *subView in _pi_BannerView.subviews) {
subView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
}
return _pi_BannerView;
}
@end