Skip to content
No description, website, or topics provided.
Swift Ruby Objective-C
Branch: master
Clone or download
Latest commit 396227a Jul 22, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
DrawerMenu.xcodeproj fix carthage build error Jul 12, 2019
DrawerMenu.xcworkspace support carthage Jul 12, 2019
DrawerMenu fix carthage build error Jul 12, 2019
Example add navigation button to example Jul 15, 2019
ExampleTests support carthage Jul 12, 2019
Pods update README Jul 22, 2019
Screenshots add sample images Jul 15, 2019
.gitignore support carthage Jul 12, 2019
DrawerMenu.podspec
Gemfile support carthage Jul 12, 2019
Gemfile.lock support carthage Jul 12, 2019
LICENSE update License Jul 13, 2019
Podfile support carthage Jul 12, 2019
Podfile.lock
README.md

README.md

DrawerMenu

Simple DrawerMenu
Correspond to left right

Cocoapods Carthage Swift Platform Liscence

Demo

Slide SlideIn Overlay Parallax Floating

Requirements

  • iOS 10.0 or later
  • Swift5.0 or later

Installation

Cocoapods

pod 'DrawerMenu'

Carthage

github "y-hryk/DrawerMenu"

Usage

Setup

To the child of viewcontroller
import DrawerMenu

class ApplicationRootViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let left = UIStoryboard(name: "Left", bundle: nil).instantiateInitialViewController()!
        let center = UIStoryboard(name: "Center", bundle: nil).instantiateInitialViewController()!

        let drawer = DrawerMenu(center: center, left: left)
        addChild(drawer)
        view.addSubview(drawer.view)
        drawer.didMove(toParent: self)
    }
}
RootViewController
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.backgroundColor = .white

    let left = UIStoryboard(name: "Left", bundle: nil).instantiateInitialViewController()!
    let center = UIStoryboard(name: "Center", bundle: nil).instantiateInitialViewController()!

    let drawer = DrawerMenu(center: center, left: left)
    window?.rootViewController = drawer
    window?.makeKeyAndVisible()

    return true
}

Access the drawermenu from the viewcontroller

import DrawerMenu

drawer()?.open(to: .left)

Open or Close

import DrawerMenu

// method call
drawer()?.open(to: .left)
drawer()?.open(to: .left, animated: true, completion: {

})
drawer()?.close(to: .right)
drawer()?.close(to: .right, animated: true, completion: {

})

// open or close status
drawer()?.isOpenLeft
drawer()?.isOpenRight

// panGesture settings
drawer()?.panGestureType = .none
drawer()?.panGestureType = .pan
drawer()?.panGestureType = .screenEdge

Replace CenterViewController

let vc = UIViewController()
let nc = UINavigationController(rootViewController: vc)
drawer()?.replace(center: nc)

Style

Please refer to each style class for details such as shadows and details

let drawer = DrawerMenu(center: center, left: left)
drawer.style = SlideIn()

Custom style

You can customize the style.

import DrawerMenu

struct CustomStyle: DrawerMenuStyle {

    func setup(drawer: DrawerMenu) {
      // Initialize. Change the hierarchy of view
    }

    func leftProgress(menuWidth: CGFloat, drawer: DrawerMenu) -> CGFloat {
        // Current progress of left menu.
        // open = 1, close = 0
    }

    func rightProgress(menuWidth: CGFloat, drawer: DrawerMenu) -> CGFloat {
        // Current progress of right menu.
        // open = 1, close = 0
    }

    func leftTransition(menuWidth: CGFloat, progress: CGFloat, drawer: DrawerMenu) {
        // Operate the left menu
    }

    func rightTransition(menuWidth: CGFloat, progress: CGFloat, drawer: DrawerMenu) {
        // Operate the right menu
    }
}

License

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

You can’t perform that action at this time.