Giter Club home page Giter Club logo

InkPageIndicator Logo

Swift 5.0 Version Platform Carthage Compatible

InkPageIndicator is a beatuful UIPageControl

InkPageIndicator Logo

Requirements

  • iOS 10.0+
  • Xcode 10.2+
  • Swift 5+

Features

  • Supporting The RxSwift
  • Timing issue for fast scrolling
  • To customize UIBeizerPath and LayoutArranger

Installation

CocoaPods

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

pod 'InkPageIndicator'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

To integrate InkPageIndicator into your Xcode project using Carthage, specify it in your Cartfile:

github "InkPageIndicator/InkPageIndicator"

Run carthage update to build the framework and drag the built InkPageIndicator.framework into your Xcode project.

On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase” and add the Framework path as mentioned in Carthage Getting started Step 4, 5 and 6

Manually

  • Open up Terminal, cd into your top-level project directory, and run the following command
pod install --repo-update
open InkPageIndicator.xcworkspace

Usage

InkPageIndicator Logo

pageControl.pageIndicatorTintColor = UIColor.lightGray
pageControl.numberOfPages = items.count
pageControl.currentPageIndicatorTintColor = UIColor.black
pageControl.currentPage = 1
pageControl.dotSize = CGSize(width: 8, height: 8)
pageControl.spacing = 20

For UIPageViewController

YourUIViewController

Conform the WrapInkPageControlAdapter protocol

class YourUIViewController: UIViewController, WrapInkPageControlAdapter {
private lazy var pageContoller: AssinPageController = {
   return pageControl
}()

And set adapter to YourUIPageViewController

page.adapter = self
YourUIPageViewController

Enable swipe gesture and register delegate of scrollView, To enable swipe gesture YourUIPageViewController conform UIPageViewPageable

class YourUIPageViewController: UIPageViewController, UIPageViewPageable

override func viewDidLoad() {
   super.viewDidLoad()
   self.enableSwipeGesture(self)
   self.scrollView?.delegate = self
}

Conform the InkPagePageViewBridge protocol

extension YourUIPageViewController: InkPagePageViewBridge {
   func pageFirstIndex(viewControllers:) -> Int? {
    }
    
    var itemCount: Int {
    }
}

Conform the UIPageViewControllerDelegate protocol, And call the function below codes

extension YourUIPageViewController: UIPageViewControllerDelegate {
    func pageViewController(_:willTransitionTo:) {
        self.behavior.pageViewController(pageViewController, willTransitionTo: pendingViewControllers)
    }
    func pageViewController(_: didFinishAnimating:previousViewControllers:transitionCompleted:) {
        self.behavior.pageViewController(
            pageViewController,
            didFinishAnimating: finished,
            previousViewControllers: previousViewControllers,
            transitionCompleted: completed
        )
    }
}

Declares a variable in your YourUIPageViewController

private lazy var behavior = InkPageViewScrollingBehavior(self, adapter: self)

Conform the UIScrollViewDelegate protocol

extension YourUIViewController: UIScrollViewDelegate {
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        self.behavior.scrollViewDidScroll(scrollView)
    }
}

For UICollectionView

Conform the WrapInkPageControlAdapter protocol

class YourUIViewController: UIViewController, WrapInkPageControlAdapter {
private lazy var pageContoller: AssinPageController = {
   return pageControl
}()

Declares a variable in your 'UIViewController'

private lazy var behavior = InkCollectionViewScrollingBehavior(self, adapter: self)

Conform the InkPageCollectionViewBridge protocol

extension YourUIViewController: InkPageCollectionViewBridge {
    var itemCount: Int {
    }

    var itemWidth: CGFloat {
    }

    var contentOffset: CGPoint {
    }

    func scrollToItem(page: Int) {
    }
}

Conform the UICollectionViewDelegateFlowLayout protocol, And call the function below codes

extension UICollectionViewControllerExample: UICollectionViewDelegateFlowLayout {
    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
        self.behavior.scrollViewWillBeginDragging(scrollView)
    }
    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        self.behavior.scrollViewDidEndDragging(scrollView, willDecelerate: decelerate)

    }
    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
        self.behavior.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
    }
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        self.behavior.scrollViewDidScroll(scrollView)
    }
}

Contributing

Contributions are very welcome 🙌

License

InkPageIndicator is released under the MIT license. See LICENSE for details.

inkpageindicator's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.