前言
图片轮播是一种很常见的UI交互方式。以前一直使用着别人写的轮子。最近空闲下来,就尝试着写一个UICollectionView的图片轮播器,原理也不难。这里说一下为什么要用UICollectionView呢?因为可以实现
复用。

原理图

接下来我们直接看代码,这里为了方便,我直接用截图

WXPictureLoopView:主控制器
WXPictureLoopFlowLayout: UICollectionViewFlowLayout
WXPictureLoopCellView:UICollectionViewCell
UIImage+WXImageCategory:一个图片的分类
WXPictureLoopView.h

WXPictureLoopView.m






WXPictureLoopFlowLayout


网友评论