JXVipDetailTcell.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // JXVipDetailTcell.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/16.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXVipDetailTcell.h"
  9. #import "JXVipDetailCCell.h"
  10. @interface JXVipDetailTcell()<UICollectionViewDelegate,UICollectionViewDataSource>
  11. @property (nonatomic,weak) UICollectionView *collectionView;
  12. @end
  13. @implementation JXVipDetailTcell
  14. + (instancetype)cellWithTableView:(UITableView *)tableView
  15. {
  16. static NSString *ID = @"JXVipDetailTcell";
  17. JXVipDetailTcell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  18. if (!cell) {
  19. cell = [[JXVipDetailTcell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
  20. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  21. }
  22. return cell;
  23. }
  24. -(void)setDataArr:(NSMutableArray *)dataArr{
  25. _dataArr=dataArr;
  26. [_collectionView reloadData];
  27. }
  28. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  29. if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  30. _dataArr=[NSMutableArray array];
  31. UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
  32. flowLayout.minimumInteritemSpacing = 10;
  33. flowLayout.minimumLineSpacing = 10;
  34. flowLayout.sectionInset = UIEdgeInsetsMake(15, 60, 5, 15);
  35. flowLayout.itemSize = CGSizeMake(JX_SCREEN_WIDTH - 110, 120);
  36. flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
  37. UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 120) collectionViewLayout:flowLayout];
  38. collectionView.delegate = self;
  39. collectionView.dataSource = self;
  40. collectionView.backgroundColor=[UIColor whiteColor];
  41. self.collectionView=collectionView;
  42. [self.contentView addSubview:collectionView];
  43. [collectionView registerNib:[UINib nibWithNibName:@"JXVipDetailCCell" bundle:nil] forCellWithReuseIdentifier:@"JXVipDetailCCell"];
  44. [collectionView reloadData];
  45. }
  46. return self;
  47. }
  48. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  49. return _dataArr.count;
  50. }
  51. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  52. JXVipDetailCCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"JXVipDetailCCell" forIndexPath:indexPath];
  53. cell.layer.cornerRadius=15;
  54. cell.layer.masksToBounds=YES;
  55. vipDetailModel *model=_dataArr[indexPath.row];
  56. cell.model=model;
  57. return cell;
  58. }
  59. @end