Skip to content

A Scrolling controller to scroll through UIViewController pages from your Storyboard. Simple config for quick and easy implementation.

License

Notifications You must be signed in to change notification settings

ziligy/JGScrollerController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

icon JGScrollerController

A Scrolling controller to scroll through UIViewController pages from your Storyboard. Simple config for quick and easy implementation.

Example with menu

example-with-menu

Example with no menu or controls

example-with-none

Example with controls

example-with-controls

Example with menu pages

example-menu-pages

Example with menu & all controls

example-all

Scrolling System:

  • uses simple configuration protocol
  • links to your storyboard's UIViewControllers by ID --> no changes required
  • optional menu with live tracking
  • optional controls for next, previous, close, and page
  • pages can adopt optional procotol to recieve live scroller tracking
  • pages can call-back to scroller methods via an optional procotol
  • use auto-layout and works properly on all devices & orientations

Installation

  • via Carthage: github "ziligy/JGScrollerController"
  • or copy JGScrollerController folder to your project

Usage

  • Create a UIViewController in Interface Builder and assign JGScrollerController as Class and scroller as Storyboard ID.
  • Assign a Storyboard ID for UIViewControllers (Pages) you want to scroll.
  • Create a configuration struct that adopts JGScrollerControllerConfig protocol (see example struct below).
  • Present the scroller (see example code below).

Configuration via simple struct (example):

// this example will display all controls
// to turn off all controls set 'show' booleans to false
struct ExampleConfigAll: JGScrollerControllerConfig {

    let storyboardName = "Main"

    let scrollerControllerIdentifier = "scroller"

    // these are your page's Storyboard IDs
    let viewControllerPageIdentifiers = [
        "pageZero",
        "pageOne",
        "pageTwo",
        "pageThree"
    ]

    let showPageControl = true

    let showNextAndPreviousControls = true

    let showCloseControl = true

    let showMenu = true

    let menuOrientation: ViewOrientation = .TopCenter

    let menuHeight: CGFloat = 40

    // empty menuImages so page numbers will display
    let menuImages = [String]()
}

Present the scroller (example):

func presentScroller(scrollerConfig: JGScrollerControllerConfig) {

        var scrollerController: JGScrollerController!

        let storyboard = UIStoryboard(name: scrollerConfig.storyboardName, bundle: nil)

        scrollerController = storyboard.instantiateViewControllerWithIdentifier(scrollerConfig.scrollerControllerIdentifier) as! JGScrollerController

        scrollerController.initScrollerController(scrollerConfig)

        self.presentViewController(scrollerController, animated: true, completion: nil)
    }

Live tracking

To include live scroller tracking on your pages adopt the JGScrollPage protocol

/// adopt this to recieve scroller status
protocol JGScrollPage {
    func scrollerDidScroll(positionX positionX: CGFloat, offset: CGFloat)
    func scrollerDidEndAtPage(currentPage: Int)
}

Call-back control

If you want your pages to call-back to the scroller adopt the JGScrollerControlLink protocol. Then your pages can call next, previous, gotoPage, and close methods on the scroller.

Demo Example

See attached Example project

Requirements

  • Xcode 7.2
  • Swift 2
  • iOS 9.0+

Attribution

Related

  • JGTapButton the multi-purpose button included in the menu, controls, and example.

About

A Scrolling controller to scroll through UIViewController pages from your Storyboard. Simple config for quick and easy implementation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published