测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
Released最后发布 | 2016年11月 |
SPM支持 SPM | ✗ |
由 Andrea Bizzotto 维护。
基于 UICollectionView 的 Swift 编写的图片轮播视图
如果您正在使用 Cocoapods,请简单地将其添加到 Podfile 中,然后在终端中输入 'pod install'。
pod 'MVCarouselCollectionView'
或者,您可以通过以下步骤将其作为 git submodule 安装
以下是一个使用 MVCarouselCollectionView 的视图控制器示例实现。更高级的使用示例请参考演示应用程序。
import MVCarouselCollectionView
class CarouselViewController: UIViewController, MVCarouselCollectionViewDelegate {
// Local images
let imagePaths = [ "image1.png", "image2.png", "image3.png" ]
// Closure to load local images with UIImage.named
let imageLoader: ((imageView: UIImageView, imagePath : String, completion: (newImage: Bool) -> ()) -> ()) = {
(imageView: UIImageView, imagePath : String, completion: (newImage: Bool) -> ()) in
imageView.image = UIImage(named:imagePath)
completion(newImage: imageView.image != nil)
}
@IBOutlet var collectionView : MVCarouselCollectionView!
override func viewDidLoad() {
super.viewDidLoad()
configureCollectionView()
}
func configureCollectionView() {
// NOTE: the collectionView IBOutlet class must be declared as MVCarouselCollectionView in Interface Builder, otherwise this will crash.
collectionView.selectDelegate = self
collectionView.imagePaths = imagePaths
collectionView.commonImageLoader = self.imageLoader
collectionView.maximumZoom = 2.0
collectionView.reloadData()
}
// MARK: MVCarouselCollectionViewDelegate
func carousel(carousel: MVCarouselCollectionView, didSelectCellAtIndexPath indexPath: NSIndexPath) {
// Do something with cell selection
}
func carousel(carousel: MVCarouselCollectionView, didScrollToCellAtIndex cellIndex : NSInteger) {
// Page changed, can use this to update page control
}
}
MVCarouselCollectionView 设计用于启用分页。请确保以下属性已设置
已知演示应用程序仅在纵向模式下运行良好。界面旋转/大小类更改不受支持。
pod 'MVCarouselCollectionView', '1.0.5'
版权所有 (c) 2015-2016 Andrea Bizzotto [email protected]
以下是对本软件及其相关文档文件(以下简称“软件”)的副本获取者的许可授权,该许可授权是免费的,不得限制使用、复制、修改、合并、发布、分发、再许可或/和出售软件副本的权利,并允许将软件提供给他人,以便他们进行上述行为,但以下条件例外。
以上版权声明和许可声明应包含在软件的任何副本或大部分内容中。
软件按“原样”提供,不提供任何形式的保证,无论是明示的还是推定的,包括但不限于对适销性、针对特定目的的适用性和非侵权的保证。在任何情况下,作者或版权所有者都不应对因合同、侵权或任何其他行为产生的任何索赔、损害或其他责任承担责任,无论这些责任是源于、由或与软件或对软件的使用或其他处理相关。