Giter Site home page Giter Site logo

kristoff2016 / interactivesidemenu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from handsomecode/interactivesidemenu

0.0 2.0 0.0 10.13 MB

iOS Interactive Side Menu written in Swift.

License: Apache License 2.0

Ruby 2.23% Objective-C 4.07% Swift 93.69%

interactivesidemenu's Introduction

#Interactive Side Menu

Swift version [![Support Dependecy Manager](https://img.shields.io/badge/support-CocoaPods | Carthage-green.svg?style=flat)](https://img.shields.io/badge/support-CocoaPods | Carthage-green.svg?style=flat) License

iOS Interactive Side Menu written in Swift.

sample

It supports following customization:

  • Animation duration
  • Visible content width
  • Content scale
  • Using spring animation with params customization
  • Animation options like animation curve

#Installation

##CocoaPods To install it through CocoaPods, add the following line to your Podfile:

pod 'InteractiveSideMenu'

##Carthage To install it through Carthage, add the following line to your Cartfile:

github "handsomecode/InteractiveSideMenu"

#Usage You should use 3 basic ViewControllers for creating subclasses for implementing your side menu.

  • MenuContainerViewController is a host for menu and content views
  • MenuViewController is a container for menu view
  • MenuItemContentControlller is a container for content that corresponds menu item

To setup your side menu you shoud do 3 things:

  • Provide implementation of base MenuViewController and assing it to menuViewController property
  • Provide implementation of menu content and assing array of content controllers to contentViewControllers property
  • Select initial content controller by calling selectContentViewController(_ selectedContentVC: MenuItemContentViewController)
import InteractiveSideMenu

class HostViewController: MenuContainerViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
     
        menuViewController = self.storyboard!.instantiateViewController(withIdentifier: "NavigationMenu") as! MenuViewController

		contentViewControllers = contentControllers()

        selectContentViewController(contentViewControllers.first!)
    }

    private func contentControllers() -> [MenuItemContentViewController] {
    	var contentList = [MenuItemContentViewController]()
    	contentList.append(self.storyboard?.instantiateViewController(withIdentifier: "First") as! MenuItemContentViewController)
    	contentList.append(self.storyboard?.instantiateViewController(withIdentifier: "Second") as! MenuItemContentViewController)
    	return contentList
	}
}

To show menu you should call showMenu() method that is available in MenuItemContentViewController class.

import InteractiveSideMenu

class FirstViewController: MenuItemContentViewController {
    
    @IBAction func didOpenMenu(_ sender: UIButton) {
        showMenu()
    }
}

To change content view you should choose desired content controller and hide menu.

let index = 2 // second menu item
guard let menuContainerViewController = self.menuContainerViewController else { return }
let contentController = menuContainerViewController.contentViewControllers[index]
menuContainerViewController.selectContentViewController(contentController)
menuContainerViewController.hideMenu()

To customize animation for menu opening or closing you should override menuTransitionOptionsBuilder() method that is available in MenuContainerViewColtroller class.

override func menuTransitionOptionsBuilder() -> TransitionOptionsBuilder? {
   return TransitionOptionsBuilder() { builder in
       builder.duration = 0.5
       builder.contentScale = 1
   }
}

See Sample for more details.

Requirements

  • iOS 8.0+
  • Xcode 8.1+
  • Swift 3.0+

License

InteractiveSideMenu is available under the Apache License, Version 2.0. See the LICENSE file for more info.

interactivesidemenu's People

Contributors

andreyarzhannikov avatar alexkorovyansky avatar

Watchers

James Cloos avatar Kristoff IBell 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.