Skip to content

carabina/LXGalleryView

 
 

Repository files navigation

LXGalleryView

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

LXGalleryView is a customizable slideshow for custom cells.

Requirements

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

Installation

CocoaPods

You can use CocoaPods to install LXGalleryView by adding it to your Podfile:

pod 'LXGalleryView'

Usage

Create a 'LXGalleryView' Instance.

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)

Register a custom cell to the LXGalleryView. Cell size automatically adjusts to 'LXGalleryView' bounds.

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

Implement the 'LXGalleryViewDataSource' protocol.

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

Additional methods, properties & delegate

Public Methods:

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

Public Properties:

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

Delegate protocol:

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

Donation

If you like my open source libraries, you can sponsor it! ☺️

paypal

Author

Leon Hoppe, leonhoppe98@gmail.com

License

Distributed under the MIT license. See LICENSE for more information.

About

Customizable slideshow for custom cells

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.5%
  • Ruby 3.5%