Swiftpack.co - Package - LastManifold/LastManifoldInfiniteCarousel

Last Manifold Infinite Carousel

infiniteCaruoselGif

Carthage Compatible License Platform Swift

Description

LastManifoldInfiniteCarousel is @IBDesignable extension to UIView you can easily create an infinite carousel from your views. Works with at least three views.

Installation

LastManifoldInfiniteCarousel is available through Carthage. To install just write into your Cartfile:

github "LastManifold/LastManifoldInfiniteCarousel"

Usage

Create UIView in your .nib or .storyboard file, and add

LMInfiniteCarousel

as class.

Connect outlet to View Controller

@IBOutlet  weak  var  infiniteCarousel: LMInfiniteCarousel!

In ViewDidAppear load your slides.

override func viewDidAppear(_ animated: Bool) {
	super.viewDidAppear(animated)
	guard let view1 = Bundle.main.loadNibNamed("View1", owner: self, options: nil)?.first as? UIView,
	let view2 = Bundle.main.loadNibNamed("View2", owner: self, options: nil)?.first as? UIView,
	let view3 = Bundle.main.loadNibNamed("View3", owner: self, options: nil)?.first as? UIView else { return }

	infiniteCarousel.slides = [view1, view2, view3]
}

Warning

If You have

<Your App>[Storyboard] Unknown class LMInfiniteCarousel in Interface Builder file.

error after run, add

LastManifoldInfiniteCarousel

as module.

lastManifoldCustomClass

Configuration

LastManifoldInfiniteCarousel gives user possibility to customize view.

You can set it in the interface builder, or you can set it programmatically. Slides are loaded proportionally to superview.

widthPercent //The width of the main slide proportional to superview(default: 70)
heightPercent //The height of the main slide proportional to superview(default: 70)
sideViewPercentSize //Proportional size of side slides to the main slide(default: 70)
slidesOffset //Distance between slides(default: 10)

Example:

infiniteCarousel.widthPercent = 80

Or in interface builder

LastManifoldChangeView

You can add UIPageControl and take its value from number of pages from getSlidesCount() func.

pageControl.numberOfPages = infiniteCarousel.getSlidesCount()

LMInfiniteCarouselDelegate

To update UIPageControl, use the pageChanged() func from delegate. Add

infiniteCarousel.delegate = self

and

extension  ViewController: LMInfiniteCarouselDelegate {
	func  pageChanged() {
		pageControl.currentPage = infiniteCarousel.getCurrentSlideIndex()
	}
}

Github

link
Stars: 2

Dependencies

Used By

Total: 0