//
|
// LiveListTableViewCell.m
|
// BuWanVideo2.0
|
//
|
// Created by apple on 2017/5/31.
|
// Copyright © 2017年 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "LiveListTableViewCell.h"
|
#import "LiveListCollectionViewCell.h"
|
@implementation LiveListTableViewCell
|
|
- (void)awakeFromNib {
|
[super awakeFromNib];
|
// Initialization code
|
|
_LiveList.delegate=self;
|
_LiveList.dataSource=self;
|
|
UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
|
//指定布局方式为垂直
|
flow.scrollDirection = UICollectionViewScrollDirectionVertical;
|
flow.minimumLineSpacing = 10;//最小行间距(当垂直布局时是行间距,当水平布局时可以理解为列间距)
|
flow.minimumInteritemSpacing = 8;//两个单元格之间的最小间距
|
|
[_LiveList setCollectionViewLayout:flow];
|
|
//注册瀑布流的cell
|
[_LiveList registerNib:[UINib nibWithNibName:@"LiveListCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"LiveListCollectionViewCell"];
|
|
//隐藏滚动条
|
_LiveList.showsVerticalScrollIndicator=NO;
|
_LiveList.showsHorizontalScrollIndicator=NO;
|
|
//设置背景色为透明
|
self.backgroundColor=[UIColor clearColor];
|
_LiveList.backgroundColor=[UIColor clearColor];
|
}
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
[super setSelected:selected animated:animated];
|
// Configure the view for the selected state
|
|
}
|
|
-(void)setCellData:(NSMutableArray *)cellData{
|
_cellData=cellData;
|
[_LiveList reloadData];
|
}
|
|
#pragma mark -UICollectionViewDataSource
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
return self.cellData.count;
|
}
|
|
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
NSDictionary *tempDic=_cellData[indexPath.row];
|
LiveListCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"LiveListCollectionViewCell" forIndexPath:indexPath];
|
|
NSString *PicStr=[tempDic objectForKey:@"HeadPic"];
|
PicStr=[PicStr stringByReplacingOccurrencesOfString:@"100_100"withString:@"300_300"];
|
[cell.image setYthImageWithURL:PicStr placeholderImage:[UIImage imageNamed:@"默认加载图片"]];
|
cell.name.text=[tempDic objectForKey:@"Name"];
|
cell.numPeople.text=[NSString stringWithFormat:@"%@人在观看",[tempDic objectForKey:@"LiveNum"]];
|
|
//添加阴影
|
cell.layer.masksToBounds = NO;
|
cell.layer.contentsScale = [UIScreen mainScreen].scale;
|
cell.layer.shadowOpacity = 0.7f;
|
cell.layer.shadowRadius = 1.0f;
|
cell.layer.shadowOffset = CGSizeMake(0,2);
|
cell.layer.shadowPath = [UIBezierPath bezierPathWithRect:cell.bounds].CGPath;
|
cell.layer.shadowColor = kGlobalLightGreyColor_223.CGColor;
|
//设置缓存
|
cell.layer.shouldRasterize = YES;
|
//设置抗锯齿边缘
|
cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
|
|
return cell;
|
}
|
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
|
return 1;
|
}
|
#pragma mark -UICollectionViewDelegate
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
NSIndexPath *index=[NSIndexPath indexPathForRow:indexPath.row inSection:_tableViewindex.section];
|
self.clickIndexpath(index);
|
}
|
|
#pragma mark -UICollectionViewDelegateFlowLayout
|
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
|
return CGSizeMake((KScreenW-8)/2-1, (KScreenW-8)/2+40);
|
}
|
|
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
|
return UIEdgeInsetsMake(0, 0, 0, 0);//分别为上、左、下、右
|
}
|
|
@end
|