123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // JXVipCenterView.m
- // shiku_im
- //
- // Created by 123 on 2020/5/30.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXVipCenterView.h"
- #import "JXVipDetailCCell.h"
- @interface JXVipCenterView()<UICollectionViewDelegate,UICollectionViewDataSource>
- @property (nonatomic,weak) UICollectionView *collectionView;
- @end
- @implementation JXVipCenterView
- //+(instancetype)XIBJXJXVipCenterView{
- //
- // return [[NSBundle mainBundle]loadNibNamed:@"JXVipCenterView" owner:self options:nil].firstObject;
- //}
-
- -(void)setDataArr:(NSMutableArray *)dataArr{
-
- _dataArr=dataArr;
-
- [_collectionView reloadData];
- }
- -(instancetype)initWithFrame:(CGRect)frame{
- if (self=[super initWithFrame:frame]) {
- _dataArr=[NSMutableArray array];
-
- UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
- flowLayout.minimumInteritemSpacing = 10;
- flowLayout.minimumLineSpacing = 10;
- flowLayout.sectionInset = UIEdgeInsetsMake(15, 60, 5, 15);
- flowLayout.itemSize = CGSizeMake(JX_SCREEN_WIDTH - 110, 120);
- flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
-
- UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH, 120) collectionViewLayout:flowLayout];
- collectionView.delegate = self;
- collectionView.dataSource = self;
- collectionView.backgroundColor=[UIColor whiteColor];
- self.collectionView=collectionView;
-
- [self addSubview:collectionView];
- [collectionView registerNib:[UINib nibWithNibName:@"JXVipDetailCCell" bundle:nil] forCellWithReuseIdentifier:@"JXVipDetailCCell"];
- [collectionView reloadData];
- }
-
- return self;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
-
- return _dataArr.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
-
- JXVipDetailCCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"JXVipDetailCCell" forIndexPath:indexPath];
- cell.layer.cornerRadius=15;
- cell.layer.masksToBounds=YES;
- vipDetailModel *model=_dataArr[indexPath.row];
- cell.model=model;
- return cell;
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
-
- if ([_delegate respondsToSelector:@selector(jxScrollViewDidScroll:)]) {
-
- [self.delegate jxScrollViewDidScroll:scrollView];
- }
- }
- @end
|