iOS Interactive Side Menu written in Swift.

Overview

Swift version: 5.0 CocoaPods: 2.3.1 Carthage compatible License: Apache 2.0

Interactive Side Menu

A customizable, interactive, auto expanding and collapsing side menu for iOS written in Swift.

Here are some of the ways Interactive Side Menu can be customized:

  • Animation duration
  • Visible content width
  • Content scale
  • UIView spring animations
  • Animation curves
  • Customized animation settings for different orientations

Communication

  • If you need help or found a bug, please, open an issue.
  • If you have a feature request, open an issue.
  • If you are ready to contribute, submit a pull request.
  • If you like Interactive Side Menu, please, give it a star.
  • If you use Interactive Side Menu in your application published to AppStore, send us a link and we'll create the list with applications used our library.

You can find more details into CONTRIBUTING file.

Installation

CocoaPods

To install using CocoaPods, add the following line to your Podfile:

pod 'InteractiveSideMenu'

Please, don't forget to run pod update command to update your local specs repository during migration from one version to another.

Carthage

To install using Carthage, add the following line to your Cartfile:

github "handsomecode/InteractiveSideMenu"

Usage

To implement your side menu you should subclasses the following view controllers: MenuContainerViewController and MenuViewController

  • MenuContainerViewController is the main container that hosts the side menu and content controller
  • MenuViewController is the container controller for the side menu

To add a new menu item, your view controller needs to conform to the SideMenuItemContent protocol.

Setting up the side menu can be done in three steps:

For this, Host = MenuContainerViewController subclass and Menu = MenuViewController subclass
  1. Assign Menu to the menuViewController property of Host
  2. Set the Host's contentViewControllers array with an array of SideMenuItemContent controllers
  3. Call selectContentViewController(_ selectedContentVC: MenuItemContentViewController) from Host
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
    }
}

Items content

To show menu, call showSideMenu() from any SideMenuItemContent controller.

import InteractiveSideMenu

class KittyViewController: UIViewController, SideMenuItemContent {
    
    @IBAction func openMenu(_ sender: UIButton) {
        showSideMenu()
    }
}

To change the currently visible controller, pass the desired controller to your MenuContainerViewController:

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

TabBar and Navigation controllers

To use menu with TabBar or NavigationController, ensure that you indicate UITabBarController or UINavigationController as item content directly, not any corresponding ViewControllers.

class NavigationViewController: UINavigationController, SideMenuItemContent {
}

class InnerViewController: UIViewController {

    @IBAction func openMenu(_ sender: Any) {
        if let navigationViewController = self.navigationController as? SideMenuItemContent {
            navigationViewController.showSideMenu()
        }
    }
}

Please, find UITabBarController implementation details in Sample.

Animation Customization

To customize the open and close animations, update the transitionOptions property on your MenuContainerViewColtroller subclass. The sample project does this in viewDidLoad()

override func viewDidLoad() {
   super.viewDidLoad()
   let screenSize: CGRect = UIScreen.main.bounds
   self.transitionOptions = TransitionOptions(duration: 0.4, visibleContentWidth: screenSize.width / 6)
   ...
}

To customize transition options for different orientations, override viewWillTransition(to:with:) and update the transitionOptions. This can also be done with trait collections using traitCollectionDidChange(_:)

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
    var options = TransitionOptions()
    options.duration = size.width < size.height ? 0.4 : 0.6
    options.visibleContentWidth = size.width / 6
    self.transitionOptions = options
}

Check out the Sample project for more details and usage examples.

Known Issues

There is an issue associated with the content controller's view not properly having the safeAreaInsets set. This causes the view's layout to shift when the side menu is closed. The issue appears to be tied to the transition options contentScale setting. Choosing a value in the range 0.87 - 0.91 causes the safeAreaInsets.top to be set to 0.0. The default value of the library is no longer within this range but be mindful if changing that value for your own application.

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.

Comments
  • Using with tabbar

    Using with tabbar

    Hello i have one tabbar and navigation bar for each item inside tabbar.

    var contentList = [MenuItemContentViewController]()
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let tabbarVC = storyboard.instantiateViewController(withIdentifier: "TabBarViewController") as! TabBarViewController
    contentList.append(tabbarVC as MenuItemContentViewController)
    

    I am trying to add tabbar but it gives me an error. Do you know how can i use with tabbar ?

    enhancement 
    opened by ghost 15
  •  showSideMenu() not working in UIViewController

    showSideMenu() not working in UIViewController

    if present storyboard in UIViewController showSideMenu() not working

    let presentAA = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "AA") as! AAViewController
            self.present(presentAA, animated: false, completion: nil)
    
    
    //not working 
    func menu() {
            showSideMenu()
    }
    
    question 
    opened by HalitGumus 14
  • UINavigationBar resizing issue - iOS11, Swift 3, Xcode9

    UINavigationBar resizing issue - iOS11, Swift 3, Xcode9

    Hello guys, first off very nice library!

    Intro

    • Xcode 9 GM
    • Swift 3.2
    • iOS 11
    • Simulator and device

    Issue

    If we embed UINavigationController as child view to MenuContainerViewController on iOS11, there is an issue with UINavigationBar height, when closing the side menu. When interaction starts, UINavigationBar will resize itself from the top to the size that will be 20pt less then the size of child view, so you will be able to see the view behind.

    This can be only seen on iOS11. I tried various stuff to fix it but without much success. If we hide navigation bar, or if the status bar is hidden, the issue will disappear.

    I'm also attaching a project so that you can check it out.

    InteractiveSideMenu-Issue.zip

    bug question 
    opened by idikic 9
  • how to call Side menu from Child view Controller class

    how to call Side menu from Child view Controller class

    Well I called Class A from side Menu and Menu icon is working fine from here. Now I Move to Class B from Class A using Navigation controller.

    I added menu icon there but open side menu is not working from there. Any idea ?

    opened by patriksharma 8
  • side menu on tabbar only I am facing problem

    side menu on tabbar only I am facing problem

    Hello

    My home viewcontroller has tab bar when I try to push any viewcontroller from side menu then tab bar is getting hidden or not able to see.

    I am new to swift and just for practice I am tried to implement this.

    here you can find my repository if you want to know what I have done.

    Thank you in advance.

    question 
    opened by shaharukhs 8
  • Cant find SideMenuItemContent and TransitionOptions in InteractiveSideMenu

    Cant find SideMenuItemContent and TransitionOptions in InteractiveSideMenu

    I recently added InteractiveSideMenu through Cocoapods and I could not Set my UINavigationController protocol to SideMenuContent. And also to set the visible width I cannot see the TransitionOptions. Please Help!

    I checked ChangeLogs and even forums, couldn't find any reference of anyone using it. Everyone uses the earlier version only. Even the changelog mentions use of TransitionOptions. How to go about it?

    question 
    opened by uncommonthinker 7
  • showSideMenu() no response

    showSideMenu() no response

    In SideMenuItemContent added this code:

    func openMenu() {
        showSideMenu()
    }
    

    and:

    menuButton.addTarget(self, action: #selector(openMenu), for: .touchUpInside)
    

    But when I click the button there is no response.

    question 
    opened by Recouse 6
  • Menu Opening Up on Swipe But Not On Clicking Button

    Menu Opening Up on Swipe But Not On Clicking Button

    I am trying to open the Side Menu by clicking a button, but the menu isn't opening . I am using the showSideMenu() function, and also have the SideMenuItemContent Delegate present ,but the side view isn't coming .

    question 
    opened by abhimasand 5
  • have a navigationviewcontroller support ?

    have a navigationviewcontroller support ?

    i want to use navigationviewcontroller on my one of view controller instantiate from your api but i getting this error. Could not cast value of type 'Mosyo.EntriesController' to 'UINavigationController'

    let nav = segue.destination as! UINavigationController
    let productListController = nav.topViewController as! EntriesController
          
    let cell = sender as! UICollectionViewCell
    let indexPath = self.collectionView!.indexPath(for: cell)
    

    how can i fix this ?

    thanks.

    enhancement 
    opened by cagricolak 5
  • Rotation

    Rotation

    Possible to disable rotation on all the sub pages except 1? I've tried many of the solutions on SO, for NavBar UI, but they don't seem to work with this.

    Thanks, Dave

    enhancement 
    opened by DaveInTO 5
  • App crashing on IOS 13

    App crashing on IOS 13

    App crashing as soon as I click on Side menu button

     *** Assertion failure in -[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3899.13.13/UIApplication.m:5240
    2019-10-14 18:05:26.260454+0530 POA[6475:1240923] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'
    
    opened by patriksharma 4
  • Pod Update not giving latest code ,Missing black screen code

    Pod Update not giving latest code ,Missing black screen code

    Hi,

    I am facing block screen issue and when I went for update the pod got success but when I checked your latest fix so that was missing and also check Version : 2.3 Build : 1.0 and I think you have fixed this in build 1.1 so please let me know how to get latest code.

    opened by amitsanvedi 0
  • Getting crash

    Getting crash

    Some time getting crash long this SDK, I shared crash logs details following:

    Crashed: com.apple.main-thread EXC_BREAKPOINT 0x00000001ef8d4f94 0 libswiftCore.dylib + 364 1 (Missing) 2 (Missing) 3 InteractiveSideMenu $s19InteractiveSideMenu0cA10TransitionC9handlePan33_F739404E431263E64308A24F6DED6690LL10recognizerySo22UIPanGestureRecognizerC_tF + 648 4 InteractiveSideMenu $s19InteractiveSideMenu0cA10TransitionC21handlePanPresentation10recognizerySo22UIPanGestureRecognizerC_tFToTm + 56 5 UIKitCore + 68 6 (Missing) 7 (Missing) 8 (Missing) 9 (Missing) 10 (Missing) 11 (Missing) 12 (Missing) 13 (Missing) 14 (Missing) 15 (Missing) 16 (Missing) 17 (Missing) 18 (Missing) 19 (Missing) 20 (Missing) 21 (Missing) 22 (Missing) 23 (Missing) 24 (Missing) 25 libdyld.dylib + 4

    opened by iFaxiOS 0
  • Opening a specific view from app delegate.

    Opening a specific view from app delegate.

    Hi, Thanks for awesome library. I have 5 view controllers on side menu. 1- Home 2- Conversations, 3- Profile, 4- Notifications and 5- Settings. I opened Homeviewcontroller after sign in page every thing works as expected. Now I have a scenario. When user receive a push notification on click, he should navigate to 4- Notificationview controller. Can you please help me out? On receiving push notification app will opens and it should navigate to 4 view rather than first view. Thanks again

    opened by khurramtnc 0
Releases(2.3)
  • 2.3(Feb 20, 2018)

    Changed

    • Renamed SideMenuItemShadow to SideMenuItemOptions to allow for additional visual properties to be changed. (Sorry for the volitility. The new name gives better flexibility going forward.)
    • Moved the drop shadow customization for the opened menu item to a property on SideMenuItemOption called shadow. Use the Shadow struct now to assign your custom values.
    • MenuContainerViewController's shadowOptions property has been renamed to currentItemOptions
    Source code(tar.gz)
    Source code(zip)
  • 2.2(Feb 9, 2018)

    Added

    • Ability to globally change the drop shadow of the current content view while the menu is open (#61)
    • New sample project controller to tweak the transition settings
    • Status bar color can now be updated on a controller by controller basis

    Changed

    • Changed default contentScale value from 0.88 to 0.86 (#53, #66, #72)
    • Updated sample project to better reflect the README demo gif

    Breaking

    • Dropped support for iOS 8
    Source code(tar.gz)
    Source code(zip)
  • 2.1(Oct 22, 2017)

  • 2.0(Jun 7, 2017)

    Added

    • UITabBarController and UINavigationController menu items support
    • Rotation support
    • Public methods documentation in code
    • CHANGELOG file

    Changed

    • Renamed showMenu()/hideMenu() methods to showSideMenu()/hideSideMenu()
    • Reworked Sample

    Fixed

    • Customization of spring animation parameters
    • Displaying horizontal images in Sample
    Source code(tar.gz)
    Source code(zip)
Owner
Handsome
Handsome
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022
A simple side menu for iOS written in Swift.

ENSwiftSideMenu A lightweight flyover side menu component for iOS with the UIDynamic's bouncing animation, UIGestures and UIBlurEffect. Allows you to

Evgeny Nazarov 1.8k Dec 21, 2022
A side menu controller written in Swift for iOS

Description SideMenuController is a custom container view controller written in Swift which will display the main content within a center panel and th

Teo 1.2k Dec 29, 2022
Beautiful iOS side menu library with parallax effect. Written in Swift

AKSideMenu AKSideMenu is a double side menu library with parallax effect. Example Project See the contained examples to get a sample of how AKSideMenu

Diogo Autilio 280 Dec 6, 2022
A simple customizable side menu written in SwiftUI.

NSideMenu Description A simple customizable side menu written in SwiftUI. Give a Star! ⭐ Feel free to request an issue on github if you find bugs or r

null 5 Oct 10, 2022
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less.

▤ SideMenu If you like SideMenu, give it a ★ at the top right of this page. SideMenu needs your help! If you're a skilled iOS developer and want to he

Jon Kent 5.4k Dec 29, 2022
iOS 7/8 style side menu with parallax effect.

RESideMenu iOS 7/8 style side menu with parallax effect inspired by Dribbble shots (first and second). Since version 4.0 you can add menu view control

Roman Efimov 7.2k Dec 28, 2022
Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. 🌶

RHSideButtons ?? Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app

Robert Herdzik 166 Nov 14, 2022
Animated side menu with customizable UI

Side Menu Animated side menu with customizable UI. Made in Yalantis. Check this project on dribbble. Check this project on Behance. Requirements iOS 7

Yalantis 2.7k Dec 27, 2022
Simple side option menu with clean code princibles

SwiftUISideMenu Simple side option menu with clean code princibles.

Mehmet Karanlık 12 May 23, 2022
A Slide Menu, written in Swift, inspired by Slide Menu Material Design

Swift-Slide-Menu (Material Design Inspired) A Slide Menu, written in Swift 2, inspired by Navigation Drawer on Material Design (inspired by Google Mat

Boisney Philippe 90 Oct 17, 2020
Swift-sidebar-menu-example - Create amazing sidebar menu with animation using swift

 SWIFT SIDEBAR MENU EXAMPLE In this project I create a awesome side bar menu fo

Paolo Prodossimo Lopes 4 Jul 25, 2022
Slide-Menu - A Simple Slide Menu With Swift

Slide Menu!! Весь интерфейс создан через код

Kirill 0 Jan 8, 2022
EasyMenu - SwiftUI Menu but not only button (similar to the native Menu)

EasyMenu SwiftUI Menu but not only button (similar to the native Menu) You can c

null 10 Oct 7, 2022
Hamburger Menu Button - A hamburger menu button with full customization

Hamburger Menu Button A hamburger menu button with full customization. Inspired by VinhLe's idea on the Dribble How to use it You can config the looks

Toan Nguyen 114 Jun 12, 2022
Interactive view transition to display menus with flowing and bouncing effects in Swift

FlowingMenu FlowingMenu provides an interactive transition manager to display menu with a flowing and bouncing effects. The Objective-C countepart is

Yannick Loriot 975 Dec 21, 2022
iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.

SlideMenuControllerSwift iOS Slide View based on iQON, Feedly, Google+, Ameba iPhone app. Installation CocoaPods pod 'SlideMenuControllerSwift' Carth

Yuji Hato 3.3k Dec 29, 2022
ExpandingMenu is menu button for iOS written in Swift.

ExpandingMenu ExpandingMenu is written in Swift. Requirements iOS 8.0+ Xcode 10.0+ Swift 3.x+ Installation CocoaPods You can install CocoaPods with th

null 454 Dec 7, 2022
iOS Slide Menu Controller. It is written in pure swift.

SlideMenuController Requirements iOS 9+ Installation SlideMenuController is available through CocoaPods. To install it, simply add the following line

Myung gi son 40 Jan 16, 2022