Giter Site home page Giter Site logo

mhslidingmenu's Introduction

MHSlidingMenu

MHSlidingMenu is cool component you can use in your projects. If you are intrested in to implement MHSlidingMenu like Uber or Twitte, you can follow these below easy steps to use this cool feature in your projects:

Usage

  • Copy and paste files of Controller/Base on your project.
  • Use MHBaseSlidingController controller as your rootViewController in AppDelegate.swift. use below function to configure rootViewController.
    private func setupApplication() {
        window = UIWindow(frame: UIScreen.main.bounds)
        guard let window = self.window else { return }
        
        let baseController = PrimaryViewController()
        let menuController = MenuController()
        
        let config = MHSlidingCofig(direction: .RTL, mode: .slideIn, statusbarStyleWhenMenuIsOpen: .default, menuWidth: 310)
        
        
        let rootViewController = MHBaseSlidingController(baseController: baseController, menuController: menuController, config: config)
        window.makeKeyAndVisible()
        window.rootViewController = rootViewController
        window.backgroundColor = .white
    }

baseController is a controller you want to show it when app run as first time.

menuController is a controller you want to show it as Menu in left/right side.

config is a instance of MHSlidingCofig has these below properies:

  • direction: threre two direction you can use. left to right OR right to left.

  • mode: threre two modes you can use. slideIn OR slidOut.

  • statusbarStyleWhenMenuIsOpen: style that you prefer for your status bar when menu is open.

  • menuWidth: an obvious propertiy :D

NOTE: Don't forget to call setupApplication() in AppDeligate.swift file.

  • In MHBaseSlidingController class there are three public functions you can use them.

    • showNewViewController(_ newController: UIViewController, completion: (() -> Void)? = nil) show new controller in main screen.

    • openMenu() open the menu.

    • closeMenu() close the menu.

To use these functions in your controllers, follow below guide:

   guard let rootViewController = (UIApplication.shared.keyWindow?.rootViewController as? MHBaseSlidingController) else { return }
   rootViewController.openMenu()

Or

   guard let rootViewController = (UIApplication.shared.keyWindow?.rootViewController as? MHBaseSlidingController) else { return }
   rootViewController.showNewViewController(NewViewController())

  • MHBaseSlidingController class has a delegate property that has four functions:
 @objc protocol BaseSlidingControllerDelegate: class {
   func menuDidOpen()
   func menuDidClose()
   
   func menuWillOpen()
   func menuWillClose()
 }

Every controller can conform MHBaseSlidingControllerDelegate protocol and to set delegate property of MHBaseSlidingController class, use below code:

  guard let rootViewController = UIApplication.shared.keyWindow?.rootViewController as? MHBaseSlidingController else { return }
  rootViewController.delegate = self

Screenshots

Contant Me

mhslidingmenu's People

Contributors

omidgolparvar avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.