CCLoopCollectionView 0.0.4

CCLoopCollectionView 0.0.4

CCC 维护。



  • chuanchuan cui

CCLoopCollectionView

Swift 的 loop UICollectionView(包含 UIPageControl)。

一、安装方法:

pod 'CCLoopCollectionView'

二、使用方法:

1.纯代码:

let v = CCLoopCollectionView(frame: CGRect(x: 30, y: 60, width: 175, height: 100)) //根据frame创建view

v.contentAry = tempAry as [AnyObject] //给轮播图赋值内容(可以为UIImage或UIString)

v.enableAutoScroll = true //是否开始自动循环

v.timeInterval = 2.0 //循环间隔时间

v.showPageControl = false //是否显示UIPageControl,默认显示

v.currentPageControlColor = UIColor.brown //UIPageControl当前颜色

v.pageControlTintColor = UIColor.cyan //UIPageControl其它颜色

v.getClickedIndex { (index) in //获取当前点击的 item 的 index

print("1--- = \(index)")

}

view.addSubview(v) //添加到父视图

2.storyboard:

①拖拽一个 UIView 到 VC 上,将其 class 改为 CCLoopCollectionView,并赋值 IBOutlet,命名为 v。

②在对应的 swift 文件中添加如下代码:

v.contentAry = tempAry as [AnyObject] //给轮播图赋值内容(可以为UIImage或UIString)

v.enableAutoScroll = true //是否开始自动循环

v.timeInterval = 2.0 //循环间隔时间

v.currentPageControlColor = UIColor.red //UIPageControl 当前颜色

v.pageControlTintColor = UIColor.black //UIPageControl 其它颜色

v.getClickedIndex { (index) in //获取当前点击的 item 的 index

print("2--- = \(index)")

}