MMBannerLayout
示例
设置
使用横幅
if let layout = collection.collectionViewLayout as? MMBanerLayout {
// Space every Item
layout.itemSpace = 5.0
// Size for banner cell
layout.itemSize = self.collection.frame.insetBy(dx: 40, dy: 40).size
// scroll to inifite (ex. completed block check your content size is enough to cycle infinite)
(collection.collectionViewLayout as? MMBanerLayout)?.setInfinite(isInfinite: true, completed: { [unowned self] (result) in
// result false mean you cant infinite
})
// auto play
(collection.collectionViewLayout as? MMBanerLayout)?.autoPlayStatus = .play(duration: 2.0)
// angle need to be (0~90)
layout.angle = 45
}
使用 BannerLayoutDelegate
//(Just setting self.collectionView.delegate = [your target])
extension [your Target]: BannerLayoutDelegate {
// Current IndexPath on center
func collectionView(_ collectionView: UICollectionView, focusAt indexPath: IndexPath) {
print("Focus on \(indexPath)")
}
}
安装
MMBannerLayout 通过 CocoaPods 提供使用。要安装,只需在 Podfile 中添加以下行
(if you cant find pod command "pod repo update")
pod "MMBannerLayout"
作者
许可
MMBannerLayout 按照MIT许可提供。更多信息请查看LICENSE文件。