Xcode 9.0+
iOS 9.0+
Swift 4.0+
CocoaPods Compatible
Platform
License
LXGalleryView is a customizable slideshow for custom cells.
- Swift 4+
- iOS 9.0+
- Xcode 9+
You can use CocoaPods to install LXGalleryView by adding it to your Podfile:
pod 'LXGalleryView'
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 }
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) }
If you like my open source libraries, you can sponsor it!
Leon Hoppe, leonhoppe98@gmail.com
Distributed under the MIT license. See LICENSE for more information.