// // YOUPAIProfileContentCell.m // MSYOUPAI // // Created by xiaohaoran on 2022/3/1. // Copyright © 2022 MS. All rights reserved. // #import "YOUPAIProfileContentCell.h" #import "YOUPAIProfileCollectionCell.h" @interface YOUPAIProfileContentCell () @property (nonatomic, strong) UICollectionView *vqupcollectionView; @end @implementation YOUPAIProfileContentCell -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { [self qxSubView]; } return self; } - (instancetype)init{ self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAIProfileContentCell"]; if(self){ [self qxSubView]; } return self; } -(void)qxSubView{ UIView *bgView1 = [UIView new]; [self.contentView addSubview:bgView1]; [bgView1 mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12); make.right.mas_equalTo(-12); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; bgView1.backgroundColor = [UIColor clearColor]; bgView1.layer.shadowColor = [UIColor colorWithRed:193/255.0 green:195/255.0 blue:208/255.0 alpha:0.05].CGColor; bgView1.layer.shadowOffset = CGSizeMake(0,10); bgView1.layer.shadowOpacity = 1; bgView1.layer.shadowRadius = 10; self.backgroundColor = [UIColor clearColor]; UIView *bgView = [UIView new]; [self.contentView addSubview:bgView]; [bgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(12); make.right.mas_equalTo(-12); make.top.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; bgView.backgroundColor = [UIColor whiteColor]; bgView.layer.cornerRadius = 12; bgView.layer.masksToBounds = YES; UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; self.vqupcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout]; [bgView addSubview:self.vqupcollectionView]; [self.vqupcollectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.left.mas_equalTo(0); make.right.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; self.vqupcollectionView.backgroundColor = [UIColor clearColor]; self.vqupcollectionView.showsVerticalScrollIndicator = NO; self.vqupcollectionView.showsHorizontalScrollIndicator = NO; self.vqupcollectionView.bounces = NO; [self.vqupcollectionView registerClass:[YOUPAIProfileCollectionCell class] forCellWithReuseIdentifier:NSStringFromClass([YOUPAIProfileCollectionCell class])]; self.vqupcollectionView.delegate = self; self.vqupcollectionView.dataSource = self; } #pragma mark - (void)setVqupaipdataArr:(NSArray *)vqupaipdataArr{ _vqupaipdataArr = vqupaipdataArr; [self.vqupcollectionView reloadData]; } /** 返回区数 @param collectionView 集合视图 @return 返回区数 */ - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } /** 返回项目数 @param collectionView 集合视图 @param section 区 @return 项目数 */ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.vqupaipdataArr.count; } -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ NSMutableDictionary *cellData = self.vqupaipdataArr[indexPath.item]; YOUPAIProfileCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([YOUPAIProfileCollectionCell class]) forIndexPath:indexPath]; cell.backgroundColor = [UIColor clearColor]; cell.vqupiconImageView.image = [cellData valueForKey:@"image"]; cell.vqupTitleLabel.text = [cellData valueForKey:@"title"]; // QXLCDynamicArrayModel *model = self.vqupalbumArray[indexPath.item]; // if (indexPath.item ==0) { // cell.vqupmoneyImage.image = [UIImage imageNamed:@"vqu_images_mine_jiaobiao_1"]; // cell.vqupmoneyImage.hidden = NO; // }else if(indexPath.item == 1 ){ // cell.vqupmoneyImage.image = [UIImage imageNamed:@"vqu_images_mine_jiaobiao_2"]; // cell.vqupmoneyImage.hidden = NO; // // }else{ // cell.vqupmoneyImage.hidden = YES; // } return cell; } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ NSMutableDictionary *cellData = self.vqupaipdataArr[indexPath.item]; NSString *title = [cellData valueForKey:@"type"]; if (self.vqupaipDidSelectBlock) { self.vqupaipDidSelectBlock(title); } } #pragma mark UICollectionViewDelegateFlowLayout /** 项目大小 @param collectionView 集合视图 @param collectionViewLayout 布局 @param indexPath 布局 @return 大小 */ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(81, 72); } #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