YOUPAIProfileContentCell.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // YOUPAIProfileContentCell.m
  3. // MSYOUPAI
  4. //
  5. // Created by xiaohaoran on 2022/3/1.
  6. // Copyright © 2022 MS. All rights reserved.
  7. //
  8. #import "YOUPAIProfileContentCell.h"
  9. #import "YOUPAIProfileCollectionCell.h"
  10. @interface YOUPAIProfileContentCell ()<UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
  11. @property (nonatomic, strong) UICollectionView *vqupcollectionView;
  12. @end
  13. @implementation YOUPAIProfileContentCell
  14. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  15. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  16. [self qxSubView];
  17. }
  18. return self;
  19. }
  20. - (instancetype)init{
  21. self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"YOUPAIProfileContentCell"];
  22. if(self){
  23. [self qxSubView];
  24. }
  25. return self;
  26. }
  27. -(void)qxSubView{
  28. UIView *bgView1 = [UIView new];
  29. [self.contentView addSubview:bgView1];
  30. [bgView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.mas_equalTo(12);
  32. make.right.mas_equalTo(-12);
  33. make.top.mas_equalTo(0);
  34. make.bottom.mas_equalTo(0);
  35. }];
  36. bgView1.backgroundColor = [UIColor clearColor];
  37. bgView1.layer.shadowColor = [UIColor colorWithRed:193/255.0 green:195/255.0 blue:208/255.0 alpha:0.05].CGColor;
  38. bgView1.layer.shadowOffset = CGSizeMake(0,10);
  39. bgView1.layer.shadowOpacity = 1;
  40. bgView1.layer.shadowRadius = 10;
  41. self.backgroundColor = [UIColor clearColor];
  42. UIView *bgView = [UIView new];
  43. [self.contentView addSubview:bgView];
  44. [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.mas_equalTo(12);
  46. make.right.mas_equalTo(-12);
  47. make.top.mas_equalTo(0);
  48. make.bottom.mas_equalTo(0);
  49. }];
  50. bgView.backgroundColor = [UIColor whiteColor];
  51. bgView.layer.cornerRadius = 12;
  52. bgView.layer.masksToBounds = YES;
  53. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  54. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  55. self.vqupcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
  56. [bgView addSubview:self.vqupcollectionView];
  57. [self.vqupcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.top.mas_equalTo(0);
  59. make.left.mas_equalTo(0);
  60. make.right.mas_equalTo(0);
  61. make.bottom.mas_equalTo(0);
  62. }];
  63. self.vqupcollectionView.backgroundColor = [UIColor clearColor];
  64. self.vqupcollectionView.showsVerticalScrollIndicator = NO;
  65. self.vqupcollectionView.showsHorizontalScrollIndicator = NO;
  66. self.vqupcollectionView.bounces = NO;
  67. [self.vqupcollectionView registerClass:[YOUPAIProfileCollectionCell class] forCellWithReuseIdentifier:NSStringFromClass([YOUPAIProfileCollectionCell class])];
  68. self.vqupcollectionView.delegate = self;
  69. self.vqupcollectionView.dataSource = self;
  70. }
  71. #pragma mark <UICollectionViewDataSource>
  72. - (void)setVqupaipdataArr:(NSArray *)vqupaipdataArr{
  73. _vqupaipdataArr = vqupaipdataArr;
  74. [self.vqupcollectionView reloadData];
  75. }
  76. /**
  77. 返回区数
  78. @param collectionView 集合视图
  79. @return 返回区数
  80. */
  81. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  82. return 1;
  83. }
  84. /**
  85. 返回项目数
  86. @param collectionView 集合视图
  87. @param section 区
  88. @return 项目数
  89. */
  90. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  91. return self.vqupaipdataArr.count;
  92. }
  93. -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  94. NSMutableDictionary *cellData = self.vqupaipdataArr[indexPath.item];
  95. YOUPAIProfileCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([YOUPAIProfileCollectionCell class]) forIndexPath:indexPath];
  96. cell.backgroundColor = [UIColor clearColor];
  97. cell.vqupiconImageView.image = [cellData valueForKey:@"image"];
  98. cell.vqupTitleLabel.text = [cellData valueForKey:@"title"];
  99. // QXLCDynamicArrayModel *model = self.vqupalbumArray[indexPath.item];
  100. // if (indexPath.item ==0) {
  101. // cell.vqupmoneyImage.image = [UIImage imageNamed:@"vqu_images_mine_jiaobiao_1"];
  102. // cell.vqupmoneyImage.hidden = NO;
  103. // }else if(indexPath.item == 1 ){
  104. // cell.vqupmoneyImage.image = [UIImage imageNamed:@"vqu_images_mine_jiaobiao_2"];
  105. // cell.vqupmoneyImage.hidden = NO;
  106. //
  107. // }else{
  108. // cell.vqupmoneyImage.hidden = YES;
  109. // }
  110. return cell;
  111. }
  112. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  113. NSMutableDictionary *cellData = self.vqupaipdataArr[indexPath.item];
  114. NSString *title = [cellData valueForKey:@"type"];
  115. if (self.vqupaipDidSelectBlock) {
  116. self.vqupaipDidSelectBlock(title);
  117. }
  118. }
  119. #pragma mark UICollectionViewDelegateFlowLayout
  120. /**
  121. 项目大小
  122. @param collectionView 集合视图
  123. @param collectionViewLayout 布局
  124. @param indexPath 布局
  125. @return 大小
  126. */
  127. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  128. return CGSizeMake(81, 72);
  129. }
  130. #pragma mark - X间距
  131. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  132. return 9.0;
  133. }
  134. //设置段落的内边距
  135. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  136. {
  137. return UIEdgeInsetsMake(0,0,0,0);//UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right)
  138. }
  139. @end