adv

AdvancedPageControl

A simple yet powerful page control indicator animations library for iOS.

Showing:

Popularity

Downloads/wk

0

GitHub Stars

167

Maintenance

Last Commit

5mos ago

Contributors

2

Package

Dependencies

0

License

MIT

Categories

Readme

AdvancedPageControl

Version License Platform

Buy Me A Coffee

A simple yet powerful page control indicator animations library for iOS, Written in Swift.

Example

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

Installation

AdvancedPageControl is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AdvancedPageControl'

Effects

  • Color Blend
  • Drop
  • ExtendedDot
  • Jump
  • Scale
  • Slide
  • Swap
  • Worm
  • ThinWorm
  • ThinWormHead
  • Scrolling
  • Infinite

Usage

I'm using it with expanded UICollectionView, create a collection view and link the DataSource and Delegate to your ViewController, and add UICollectionViewDeleageFlowLayout

class ViewController: UIViewController,
    UICollectionViewDataSource,
    UICollectionViewDelegate,
    UICollectionViewDelegateFlowLayout { ....

Then add these methods:

   func numberOfSections(in collectionView: UICollectionView) -> Int {
       return 5
   }
   
   func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
       return 1
   }
   
   func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
       return collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
   }
   
   
   func collectionView(_ collectionView: UICollectionView,
                       layout collectionViewLayout: UICollectionViewLayout,
                       sizeForItemAt indexPath: IndexPath) -> CGSize {
       return CGSize(width: collectionView.frame.width, height: 250) // This is to restric the item width and heigth to achive the single item preview
   }

Tick 'Scrolling enabled' and 'Paging enabled' Checkboxes in storyboard UICollectionView properties

Then add this method and pass the offset of the scrolling for UICollectionView, and width of the UICollectionView, to the pageControl , setCurrentItem, Method

func scrollViewDidScroll(_ scrollView: UIScrollView) {
      let offSet = scrollView.contentOffset.x
      let width = scrollView.frame.width
      
      pageControl.setPageOffset(offSet/width)
      
      // OR
      let index = Int(round(offSet/width))
      pageControl.setPage(index) // This will animate the page controll transition, whenever the index is changed, no need to pass an offset of every scroll offset

  }

Then set any drawer you like in viewDidLoad Method :

pageControl1.drawer = ColorBlendDrawer()

or you can pick one of these

ColorBlendDrawer()
DropDrawer()
ExtendedDotDrawer()
JumpDrawer()
ScaleDrawer()
SlideDrawer()
SwapDrawer()
ThinWormDrawer()
ThinWormHeadsDrawer()
WormDrawer()
Scrolling()
Infinite()

Alt Text

Customization

ScaleDrawer(numberOfPages:Int? = 5,
            height: CGFloat? = 16,
            width: CGFloat? = 16,
            space: CGFloat? = 16,
            radius: CGFloat? = 16,
            currentItem: CGFloat? = 0,
            indicatorColor: UIColor? = .red,
            dotsColor: UIColor? = .lightGray)

Author

Mohanned Binmiskeen, mohn93@gmail.com

License

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100