// // YOUPAIZYUserZiLiaoDTCell.m // VQU // // Created by 肖浩然的mac on 2021/7/10. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAIZYUserZiLiaoLWCell.h" #import "YOUPAIZYUserZiLiaoBHPhotoCell.h" @interface YOUPAIZYUserZiLiaoLWCell() @property (nonatomic, strong) UICollectionView *youpaipcollectionView; @end @implementation YOUPAIZYUserZiLiaoLWCell -(instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { [self youpaifsetSubView]; } return self; } -(void)youpaifsetSubView{ UIView *titleView = [UIView new]; [self.contentView addSubview:titleView]; [titleView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.top.mas_equalTo(0); make.height.mas_equalTo(43); }]; titleView.backgroundColor = LCWhiteColor; self.youpaiptitleLabel = [[UILabel alloc] init]; self.youpaiptitleLabel.font = LCBoldFont(14); [titleView addSubview:self.youpaiptitleLabel]; [self.youpaiptitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(0); make.left.mas_equalTo(14); }]; self.youpaiptitleLabel.textColor = [UIColor whiteColor]; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; self.youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout]; [self.contentView addSubview:self.youpaipcollectionView]; [self.youpaipcollectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(titleView.mas_bottom); make.left.mas_offset(12.f); make.right.mas_offset(-12.f); make.bottom.mas_offset(0.f); }]; self.youpaipcollectionView.userInteractionEnabled = NO; self.youpaipcollectionView.backgroundColor = LCWhiteColor; self.youpaipcollectionView.showsVerticalScrollIndicator = NO; self.youpaipcollectionView.showsHorizontalScrollIndicator = NO; self.youpaipcollectionView.bounces = NO; //arrow UIButton *arrowBtn = [UIButton new]; [self.contentView addSubview:arrowBtn]; [arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(10, 10)); make.centerY.mas_equalTo(self.youpaiptitleLabel); make.right.mas_equalTo(-6); }]; [arrowBtn setImage:[UIImage imageNamed:@"vqu_images_zhuye_ZL_arrow"] forState:UIControlStateNormal]; arrowBtn.titleLabel.font = [UIFont systemFontOfSize:10]; [arrowBtn setTitleColor:HexColorFromRGB(0xA3AABE) forState:UIControlStateNormal]; [self.youpaipcollectionView registerClass:[YOUPAIZYUserZiLiaoBHPhotoCell class] forCellWithReuseIdentifier:NSStringFromClass([YOUPAIZYUserZiLiaoBHPhotoCell class])]; self.youpaipcollectionView.delegate = self; self.youpaipcollectionView.dataSource = self; } -(void)setYoupaipdataArr:(NSArray *)dataArr{ _youpaipdataArr = dataArr; if (dataArr.count>0) { NSInteger count = 0; if (dataArr.count>=5) { count = 5; }else { count =dataArr.count; } NSMutableArray *arr = [NSMutableArray new]; for (int i = 0; i /** 返回区数 @param collectionView 集合视图 @return 返回区数 */ - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } /** 返回项目数 @param collectionView 集合视图 @param section 区 @return 项目数 */ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.youpaipdataArr.count; } -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ YOUPAIZYUserZiLiaoBHPhotoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([YOUPAIZYUserZiLiaoBHPhotoCell class]) forIndexPath:indexPath]; YOUPAILCGiftModel *model = self.youpaipdataArr[indexPath.item]; cell.backgroundColor = LCWhiteColor; NSString *imageUrl = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,model.youpaipimg]; [cell.youpaipiconImageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:nil]; cell.youpaipNumLabel.text = [NSString stringWithFormat:@"x%ld",(long)model.youpaiptotal]; cell.youpaipNameLabel.text = model.youpaipname; return cell; } #pragma mark UICollectionViewDelegateFlowLayout /** 项目大小 @param collectionView 集合视图 @param collectionViewLayout 布局 @param indexPath 布局 @return 大小 */ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(63, 95+9+17+30); } #pragma mark - X间距 - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return 9.0; } //设置段落的内边距 - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { return UIEdgeInsetsMake(0,0,0,0);//UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) } @end