Skip to content

iaaqibhussain/AHCarouselViewController

Repository files navigation

AHCarouselViewController

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

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.

Usage

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
        

Protocol

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)
    }

Result

alt tag

Author

Aaqib Hussain, [email protected]

License

AHCarouselViewController is available under the MIT license. See the LICENSE file for more info.

About

A simple carousel library written in Swift 3.

Resources

License

Stars

Watchers

Forks

Packages

No packages published