Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/caichenghan/ccbanner
自定义banner
https://github.com/caichenghan/ccbanner
Last synced: 19 days ago
JSON representation
自定义banner
- Host: GitHub
- URL: https://github.com/caichenghan/ccbanner
- Owner: CaiChenghan
- License: mit
- Created: 2020-11-03T07:40:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-08T09:08:32.000Z (almost 4 years ago)
- Last Synced: 2024-12-22T15:47:29.721Z (about 2 months ago)
- Language: Objective-C
- Size: 69.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CCBanner
[![CI Status](https://img.shields.io/travis/CaiChenghan/CCBanner.svg?style=flat)](https://travis-ci.org/CaiChenghan/CCBanner)
[![Version](https://img.shields.io/cocoapods/v/CCBanner.svg?style=flat)](https://cocoapods.org/pods/CCBanner)
[![License](https://img.shields.io/cocoapods/l/CCBanner.svg?style=flat)](https://cocoapods.org/pods/CCBanner)
[![Platform](https://img.shields.io/cocoapods/p/CCBanner.svg?style=flat)](https://cocoapods.org/pods/CCBanner)基于**UICollectionView**实现的轮播控件,可**无限循环**、**自定义**轮播内容,以及对**重用机制**的使用。
## 安装
```ruby
pod 'CCBanner', '~> 1.0.0'
```
## 使用
##### 创建对象
```
- (CCBanner *)banner {
if (_banner == nil) {
_banner = [[CCBanner alloc]init];
_banner.dataSource = self;
_banner.delegate = self;
[_banner registerClass:[BannerCell class] reuseIdentifier:@"BannerCell"];
}
return _banner;
}
```
##### 实现代理
```
- (NSInteger)numberOfItems {
return 3;
}- (__kindof UICollectionViewCell *)banner:(CCBanner *)banner itemAtIndex:(NSInteger)index {
BannerCell *cell = [banner dequeueReusableItemWithIdentifier:@"BannerCell" forIndex:index];
cell.data = [NSString stringWithFormat:@"%ld",index];
return cell;
}```
##### 自定义轮播内容
```
/// 自定义轮播cell
@interface BannerCell ()@end
@implementation BannerCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
/// 自定义cell内容
}
return self;
}@end
```