Giter VIP home page Giter VIP logo

sscustomsidemenu's Introduction

SSCustomSideMenu

Version License Platform

Alt text Alt text Alt text Alt text

Features

  • Highly customizable
  • Multiple options of animations
  • Dynamic menu size
  • Available through CocoaPods

Requirements

  • iOS 11.0+
  • Xcode 10+

Installation

CocoaPods

  • You can use CocoaPods to install SSCustomSideMenu by adding it to your Podfile:

      use_frameworks!
      pod 'SSCustomSideMenu'
    
  • In the swift file, import SSSideMenu module:

      import UIKit
      import SSCustomSideMenu
    

Manually

  • Download and drop SSCustomSideMenu folder in your project.
  • Congratulations!

Usage example

Create a subclass of SSSideMenuContainerViewController

class SideMenuViewController: SSSideMenuContainerViewController { ... }
  • In the storyboard assign a custom class SideMenuViewController you just created to a viewController. This viewController will be the container for Side menu. Alt text

    Create Menu Table

    let menuTable = SSMenuTableView()
    

    Configure Side Menu Options

    let menuCellConfig = SSMenuCellConfig()
    
    menuCellConfig.cellStyle = .defaultStyle
    
    menuCellConfig.leftIconPadding = 20
    menuCellConfig.imageToTitlePadding = 10
    menuCellConfig.imageHeight = 24
    menuCellConfig.imageWidth = 24
    
    menuCellConfig.numberOfOptions = 3
    
    menuCellConfig.selectedColor = .purple
    menuCellConfig.nonSelectedColor = .black
    
    menuCellConfig.images = [UIImage(named: "first"), UIImage(named: "second"), UIImage(named: "third")]
    menuCellConfig.titles = ["First", "Second", "Thrird"]
    
    self.menuTable.config = menuCellConfig
    

    Configure Side Menu

    let sideMenuConfig = SSSideMenuConfig()
    sideMenuConfig.animationType = .slideOut // Other options:  .slideIn, .compress(0.8, 20)
    sideMenuConfig.sideMenuPlacement = .left // Other options:  .right
    sideMenuConfig.menuWidth = UIScreen.main.bounds.width * 0.5
    
    let firstViewController = storyboard?.instantiateViewController(withIdentifier: "FirstViewController")
    let secondViewController = storyboard?.instantiateViewController(withIdentifier: "SecondViewController")
    let thirdViewController = storyboard?.instantiateViewController(withIdentifier: "ThirdViewController")
    
    sideMenuConfig.viewControllers = [firstViewController!, secondViewController!, thirdViewController!]
    
    sideMenuConfig.menuTable = menuTable
    
    self.ssMenuConfig = sideMenuConfig
    

    Delegates

    • SSCustomSideMenu provides delegate 'sideMenuDelegate' which lets developers dynamically decide which operations to perform on menu option selection

        sideMenuDelegate = self
      
    • By doing this, you will be asked to confirm to following protocol:

        extension ViewController: SSSideMenuDelegate {
            func shouldOpenViewController(forMenuOption menuOption: Int) -> Bool {
                if menuOption == 1 {
                    // Perform action for custom options (i.e logout)
                    return false
                } else {
                    return true
                }
            }
        }
      

    Open and Close Side Menu

    • SSCustomSideMenu Provides custom side menu button - 'SSMenuButton'. You only need to assign SSMenuButton custom class to your UIButton from Interface Builder

    • Manually open or close side menu :

        SSSideMenuControls.openOrCloseSideMenu()
      

Contribute

  • We would love you for the contribution to SSCustomSideMenu, check the LICENSE file for more info.

License

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

License Platform

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.