LXGalleryView 1.0.0

LXGalleryView 1.0.0

Leon Hoppe 维护。



  • 作者
  • Leon Hoppe

LXGalleryView

Xcode 9.0+ iOS 9.0+ Swift 4.0+ CocoaPods Compatible
Platform License

LXGalleryView 是一个定制的单元格幻灯片。

要求

  • Swift 4+
  • iOS 9.0+
  • Xcode 9+

安装

CocoaPods

您可以使用 CocoaPods 通过将其添加到您的 Podfile 中来安装 LXGalleryView

pod 'LXGalleryView'

用法

创建 'LXGalleryView' 实例。

let frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: 230)
let galleryView = LXGalleryView(frame: frame, delegate: self, dataSource: self)

self.view.addSubview(galleryView)

将自定义单元格注册到 LXGalleryView。单元格大小将自动调整为 'LXGalleryView' 的边界。

galleryView.galleryCollection.register(UINib(nibName: "myCustomCell", bundle: Bundle.main), forCellWithReuseIdentifier: "myCell")

实现 'LXGalleryViewDataSource' 协议。

@objc public protocol LXGalleryViewDataSource {
func galleryView(_ galleryView: LXGalleryView, numberOfItemsInSection section: Int) -> Int
func galleryView(_ galleryView: LXGalleryView, cellForItemAt: IndexPath) -> UICollectionViewCell
}

附加方法、属性及委托

公共方法

galleryView.setButtonImages(left: UIImage, right: UIImage, for state: UIControlState) // to set custom navigation buttons

公共属性

galleryView.galleryCollection: LXGalleryViewCollection // wrapped CarouselCollection (Subclass of UICollectionView)
galleryView.dataSource: LXGalleryDataSource // dataSource
galleryView.delegate: LXGalleryDelegate // delegate
galleryView.isAnimated: Bool // automatic scrolling
galleryView.duration: Double // duration until the next cell should animate in
galleryView.isInfinite: Bool // endless scrolling
galleryView.rightButton: UIButton // right navigation button
galleryView.leftButton: UIButton // left navigation button
galleryView.areButtonsHidden: Bool // turn navigation buttons on or off

委托协议

@objc public protocol LXGalleryViewDelegate {
optional func galleryViewDidPaged(_ galleryView: LXGalleryView, toPage: Int)
optional func galleryViewDidScroll(_ galleryView: LXGalleryView)
}

捐赠

如果你喜欢我的开源库,你可以资助它!☺️

paypal

作者

Leon Hoppe, [email protected]

许可

在MIT许可下分发。请参阅LICENSE获取更多信息。