To run the example project, clone the repo, and run pod install
from the Example directory first.
AHCarouselViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "AHCarouselViewController"
Is installing pod too much work? Just download the repo, copy and paste AHCarouselViewController.swift in your project.
Using AHCarouselViewController is pretty simple.
//If using pod, import AHCarouselViewController //Create and object let carousel = AHCarouselViewController(self.view.frame, carouselImages: --image array goes here--) //Auto animate default time is 1 sec carousel.carouselAnimation = true //Change animation duration carousel.carouselAnimationTimeInterval = 4 //Change Page Indicator color carousel.pageIndicatorTintColor = UIColor.black carousel.currentPageIndicatorTintColor = UIColor.white //Hide Page Indicator carousel.isPageIndicatorHidden = true //Delegate carousel.delegate = self
Conform your class to protocol AHCarouselDelegate
//Get you the number of page you are currently on func carouselDidChange(carouselViewController: AHCarouselViewController, carousel: carouselView) { let pageWidth = carousel.frame.size.width let page = carousel.contentOffset.x / pageWidth print(page) }
Aaqib Hussain, [email protected]
AHCarouselViewController is available under the MIT license. See the LICENSE file for more info.