save code
This commit is contained in:
eggmanQQQ
2024-06-21 01:37:38 +08:00
parent 7210bd9d79
commit 627748d230
56 changed files with 1281 additions and 244 deletions

View File

@@ -31,7 +31,6 @@
[self addSubview:self.pageControl];
}
-(void)installConstraints{
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0);
make.trailing.mas_equalTo(0);
@@ -43,8 +42,6 @@
make.leading.trailing.equalTo(self).inset(kGetScaleWidth(14));
make.height.mas_equalTo(kGetScaleWidth(80));
}];
}
#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
@@ -92,7 +89,7 @@
self.collectionView.hidden = _itemList.count == 0;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.collectionView reloadData];
});
});
if (_itemList.count == 0){
[self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
@@ -104,6 +101,10 @@
}
}
- (void)setRankAvatars:(NSArray *)rankAvatars {
_rankAvatars = rankAvatars;
[self.collectionView reloadData];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
@@ -111,12 +112,20 @@
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPNewHomeItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPNewHomeItemCell class]) forIndexPath:indexPath];
if(indexPath.row < self.itemList.count){
cell.itmeModel = self.itemList[indexPath.row];
cell.itemModel = self.itemList[indexPath.row];
cell.rankAvatarsModelArray = self.rankAvatars;
}
@kWeakify(self);
cell.didTapRankArea = ^{
@kStrongify(self);
PIHomeItemModel *model = [self.itemList xpSafeObjectAtIndex:indexPath.row];
if(model != nil && self.delegate && [self.delegate respondsToSelector:@selector(selectItemWithModel:)]){
[self.delegate selectItemWithModel:model];
}
};
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
@@ -125,6 +134,7 @@
[self.delegate selectItemWithModel:model];
}
}
#pragma mark -
- (UICollectionView *)collectionView{
if (!_collectionView) {
@@ -149,7 +159,7 @@
- (SDCycleScrollView *)pi_BannerView {
if (!_pi_BannerView) {
_pi_BannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImageConstant defalutBannerPlaceholder]];
_pi_BannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:[UIImageConstant defaultBannerPlaceholder]];
_pi_BannerView.backgroundColor = [UIColor redColor];
_pi_BannerView.layer.cornerRadius = 10;
_pi_BannerView.layer.masksToBounds = YES;