Code Monkey home page Code Monkey logo

mipivotpagecontroller's Introduction

MIPivotPageController

MIPivotPageController allows switching view controllers with an horizontal swipe

Setup

  • Copy the "MIPivotPageController" folder to your project.
  • Create a new instance with just a line of code
  MIPivotPageController.get(rootPages: [viewControllerA, viewControllerB, viewControllerC]) 
  • If you want, you can customize the UI with a simple closure

  MIPivotPageController.get(rootPages: [viewControllerA, viewControllerB, viewControllerC])  {
  
    $0.menuView.backgroundColor = myBlueColor
    $0.menuView.layer.shadowColor = UIColor.black.cgColor
    $0.menuView.layer.shadowOpacity = 0.3
    $0.menuView.layer.shadowOffset = CGSize(width: 0, height: 2)
    
    $0.setMenuHeight(60)
  
    $0.setLightStatusBar(true)
  
  }

  • The root view controllers (in this case viewControllerA, viewControllerB and viewControllerC) must conform the MIPivotRootPage protocol which has only one non-optional method that provide the image for the menu.
  func imageForPivotPage() -> UIImage?

There're also two usefull method like

  func rootPivotPageDidShow()
  func rootPivotPageWillHide()

that are called when a page in showed and when it's about to hide.

  • The other view controllers must inherit from MIPivotPage (which inerit from UIViewController). If you want, you can override those two methods:
    func shouldShowPivotMenu() -> Bool { return true }
    func pivotPageShouldHandleNavigation() -> Bool { return true }

If the first one return false, the menu will not be visible on that view controller. If the second one return false, the swipe (to the other root pivot pages) will be disabled for that view controller.

For a better understanding of those methods see the navigationController example in the demo.

Demo

In this repository you can also find a demo.

Info

If you like this git you can follow me here or on twitter :) @MarioIannotta

Cheers from Italy!

mipivotpagecontroller's People

Contributors

marioiannotta avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  avatar

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.