仿淘宝、京东、美团等主流App等主流菜单轮播图、Banner
一、封装热门滚动菜单,已经支持pod下载 ,请更新pod版本库
- 最新版本:0.0.6
- OC版本:
- pod搜索:pod search CGXHotBrandViewOC
- 如果搜不到去请搜索:pod search CGXHotBrandViewOC --simple
- 详情 CGXHotBrandViewOC库
二、效果图
三、使用说明
CGXHotBrandView *hotBrandView = [[CGXHotBrandView alloc] init];
hotBrandView.delegate = self;
hotBrandView.dataSource =self;
hotBrandView.minimumLineSpacing = 5;
hotBrandView.minimumInteritemSpacing = 5;
hotBrandView.edgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
hotBrandView.itemSectionCount = 2;
hotBrandView.itemRowCount = 5;
if (i==0) {
hotBrandView.pagingEnabled = YES;
hotBrandView.itemSectionCount = 2;
hotBrandView.itemRowCount = 5;
} else if(i==1){
hotBrandView.pagingEnabled = YES;
hotBrandView.itemSectionCount = 2;
hotBrandView.itemRowCount = 6;
}else{
hotBrandView.pagingEnabled = NO;
}
hotBrandView.bounces = YES;
// hotBrandView.isHavePage = NO;
CGFloat height = (ScreenHeight-kTabBarHeight-kTopHeight-40)/3.0;
hotBrandView.frame = CGRectMake(0, 10*(i+1) + i*height,ScreenWidth,height);
hotBrandView.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1];
[self.view addSubview:hotBrandView];
hotBrandView.pageHeight = 10;
hotBrandView.tag = 10000+i;
hotBrandView.showType = i+1;
hotBrandView.isAnimation = i==1 ? NO:YES;
NSMutableArray *dataArray = [NSMutableArray array];
for (int j = 0; j< 4; j++) {
NSMutableArray *rowArray = [NSMutableArray array];
for (int k = 0; k< hotBrandView.itemSectionCount*hotBrandView.itemRowCount; k++) {
CGXHotBrandModel *model = [[CGXHotBrandModel alloc] init];
model.titleStr = [NSString stringWithFormat:@"猫咪%d-%d",j,k];
model.itemColor = [UIColor whiteColor];
model.hotPicStr = imageArray[arc4random() % (imageArray.count)];
model.tagStr = (arc4random() % 2 == 0) ? @"秒杀":@"";
model.tagSpace = 10;
[rowArray addObject:model];
}
[dataArray addObject:rowArray];
}
[hotBrandView updateWithDataArray:dataArray];
- 3.可选实现CGXHotBrandCustomViewDelegate代理
// ========== 轮播自定义cell ==========
/** 如果你需要自定义cell样式,请在实现此代理方法返回你的自定义cell的class。 */
- (Class)gx_hotBrandCellClassForBaseView:(CGXHotBrandBaseView *)hotView;
/** 如果你需要自定义cell样式,请在实现此代理方法返回你的自定义cell的Nib。 */
- (UINib *)gx_hotBrandCellNibForBaseView:(CGXHotBrandBaseView *)hotView;
- 4.可选实现CGXHotBrandViewDataSource代理
/* : 轮播自定义cell 如果设置多个当根据tag值判断时, 先设置tag再设置delegate */
/** 如果你需要自定义cell样式,请在实现此代理方法返回你的自定义cell的class。 */
- (Class)gx_hotBrandCellClassForBaseView:(CGXHotBrandBaseView *)hotView;
/** 如果你需要自定义cell样式,请在实现此代理方法返回你的自定义cell的Nib。 */
- (UINib *)gx_hotBrandCellNibForBaseView:(CGXHotBrandBaseView *)hotView;
/*点击cell*/
- (void)gx_hotBrandBaseView:(CGXHotBrandBaseView *)hotView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath
AtModel:(CGXHotBrandModel *)hotModel;
/*滚动结束cell CGXHotBrandCycleView、CGXHotBrandView无效 */
- (void)gx_hotBrandBaseView:(CGXHotBrandBaseView *)hotView
ScrollEndItemAtIndexPath:(NSIndexPath *)indexPath
AtModel:(CGXHotBrandModel *)hotModel;
/* cell数据交互处理*/
- (void)gx_hotBrandBaseView:(CGXHotBrandBaseView *)hotView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
AtCell:(UICollectionViewCell *)cell
AtModel:(CGXHotBrandModel *)hotModel;
/* 正在滚动 */
- (void)gx_hotBrandBaseView:(CGXHotBrandBaseView *)hotView
ScrollAtPoint:(UIScrollView *)scrollView;
- 5.自定义cell实现CGXHotBrandUpdateCellDelegate代理方法
- (void)updateWithHotBrandCellModel:(CGXHotBrandModel *)cellModel Section:(NSInteger)section Row:(NSInteger)row