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.

Related tags

Menu SwiftySideMenu
Overview

SwiftySideMenu

SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale animation based on Pop framework. SwiftySideMenu animations are built using Pop framework to provide smooth and awesome spring animations. SwiftySideMenu is written in Objective-C and its very easy to use with Swift projects. The demo itself is based on Swift to see how easy its used with in Swift.

Installation

First you have to install Pop. Pop is available on CocoaPods. Just add the following to your project Podfile:

pod 'pop', '~> 1.0'

Then, Add the SwiftySideMenu library files to your project:

  • SwiftySideMenuViewController.h
  • SwiftySideMenuViewController.m
  • UIViewController+SwiftySideMenu.h
  • UIViewController+SwiftySideMenu.m

Usage

SwiftySideMenu is very easy to use. After adding the Pop framework and the library files, import the needed files as below:

#import "SwiftySideMenuViewController.h"
#import "UIViewController+SwiftySideMenu.h"

Incase of your project is Swift based, just add the import statements in the briding header file.

Don't have briding header file? Add a header file to your project, named [MyProjectName]-Bridging-Header.h to import any Objective-C code you want your Swift code to have access to. Then In your project build settings, go to Swift Compiler – Code Generation, and next to Objective-C Bridging Header add the path to your bridging header file, from the project’s root folder. So it could by MyProject/MyProject-Bridging-Header.h or simply MyProject-Bridging-Header.h if the file lives in the project root folder.

SwiftSideMenuViewController

SwiftySideMenuViewController is the main view controller that will be the root view controller in your project. You can set it as the root view controller from Storyboard or programmatically.

Setting Left and Center view controllers

In SwiftySideMenuViewController you use the properties centerViewController and leftViewController to set the left and center view controllers anytime. Check example:

let swiftySideMenuVC = self.window?.rootViewController as! SwiftySideMenuViewController

let centerVC = swiftySideMenuVC.storyboard?.instantiateViewControllerWithIdentifier("Center")        
let leftVC = swiftySideMenuVC.storyboard?.instantiateViewControllerWithIdentifier("Left")
        
swiftySideMenuVC.centerViewController = centerVC
swiftySideMenuVC.leftViewController = leftVC

Accessing the SwiftySideMenuViewController

SwiftySideMenuViewController instance can be accessed easily from left or center view controller by calling the property .swiftySideMenu in any UIViewController thanks to the category UIViewController+SwiftySideMenu.

Even if the center view controller is UINavigationController or UITabBarController. You can still access the SwiftySideMenuViewController from children view controllers.

In the demo project, the center view controller is embeded in UINavigationController and to toggle the side menu when the left navigation bar button is clicked, we do the following:

    @IBAction func toggleSideMenu(sender: AnyObject) {
        self.swiftySideMenu?.toggleSideMenu()
    }

Customizing The Animations Of Left & Center View Controllers

You can customize the final value of scale animation of the center view controller. As well for the center and left view controller you can customize the bounciness and speed of their animations.

swiftySideMenuVC.centerEndScale = 0.4
swiftySideMenuVC.leftSpringAnimationSpeed = 20

Toggling Side Menu

You can easily toggle (open or close) the side menu by calling the function toggleSideMenu in SwiftySideMenuViewController

swiftySideMenuVC.toggleSideMenu()

Side menu also can be toggled using swipe gestures. Swiping right will open the side menu if it was closed. Swiping left will close the side menu if it was opened. Swipe gestures are enabled by default, if you want to disable any gesture do the following:

swiftySideMenuVC.enableLeftSwipeGesture = false // disable the left swipe gesture

swiftySideMenuVC.enableRightSwipeGesture = false // disable the right swipe gesture

Setting Up The Delegate

You can set the delegate in SwiftySideMenuViewController to be notified when the animations start and finish. You will find two method in the delegate to be used:

-(void)swiftSideMenu:(SwiftySideMenuViewController *)sideMenuController animationDidStartInSide:(SwiftyMenuSide)side;

-(void)swiftSideMenu:(SwiftySideMenuViewController *)sideMenuController animationDidFinishInSide:(SwiftyMenuSide)side finished:(BOOL)finished;

SwiftyMenuSide is an enum with two values SwiftyMenuSideCenter and SwiftyMenuSideLeft.

License

The MIT License (MIT)

Copyright (c) 2015 Hossam Ghareeb ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...
Drawer view controller that easy to use!
Drawer view controller that easy to use!

KWDrawerController Drawer view controller that is easy to use! Installation CocoaPods (iOS 8+ projects) KWDrawerController is available on CocoaPods.

RadialMenu is a custom control for providing a touch context menu (like iMessage recording in iOS 8) built with Swift & POP
RadialMenu is a custom control for providing a touch context menu (like iMessage recording in iOS 8) built with Swift & POP

RadialMenu Looking for help? For $150/hr I'll help with your RadialMenu problems including integrating it into your project. Email [email protected] t

RadialMenu is a custom control for providing a touch context menu (like iMessage recording in iOS 8) built with Swift & POP
RadialMenu is a custom control for providing a touch context menu (like iMessage recording in iOS 8) built with Swift & POP

RadialMenu Looking for help? For $150/hr I'll help with your RadialMenu problems including integrating it into your project. Email [email protected] t

A simple side menu for iOS written in Swift.
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

iOS Interactive Side Menu written in Swift.
iOS Interactive Side Menu written in Swift.

Interactive Side Menu A customizable, interactive, auto expanding and collapsing side menu for iOS written in Swift. Here are some of the ways Interac

iOS 7/8 style side menu with parallax effect.
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

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

Beautiful iOS side menu library with parallax effect. Written in Swift
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

A simple customizable side menu written in SwiftUI.
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

Comments
  • Tech Help

    Tech Help

    Hi Hossam Ghareeb

    I hope this message will find you in best of your mood.

    I liked your work a lot , its just that I want to design something with similar animation but with bit difference.

    In your library , the center view controller when presented is squeezed with a spring animation to come in the center of the screen. I just want to place it in the bottom in place of center.

    Is that possible with your library? If YES , have you provided any properties/enumerations to change it or will the code need change?

    I have attached an image of design I want to create.

    Hoping for a positive response.

    Thanks & Regards Tushar Agarwal side-menu

    opened by tush010 1
Owner
Hossam Ghareeb
Hossam Ghareeb
A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram)

Unfortunately, life gets in the way sometimes and I won't be able to maintain this library any longer and upgrade this library to where it needs to be

null 5.2k Dec 31, 2022
XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers

XLPagerTabStrip is a Container View Controller that allows us to switch easily among a collection of view controllers. Pan gesture can be used to move on to next or previous view controller. It shows a interactive indicator of the current, previous, next child view controllers.

xmartlabs 6.8k Dec 27, 2022
PopMenu is pop animation menu inspired by Sina weibo / NetEase app.

PopMenu PopMenu is pop animation menu inspired by Sina weibo / NetEase app. Screenshots Installation CocoaPods With CocoaPods, add this line to your P

曾宪华 898 Nov 14, 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
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
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
TomatoVerticalMenuMania lets you create a vertical, scrollable menu to the left of the screen.

TomatoVerticalMenuMania Framework Development and compatibility Development platform: iOS Language: Swift Compatibility: iOS 13 or greater Description

Tomato Software 0 Jan 11, 2022
Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

Ivan Vorobei 965 Dec 17, 2022
Menu controller with expandable item groups, custom position and appearance animation written with Swift. Similar to ActionSheet style of UIAlertController.

Easy to implement controller with expanding menu items. Design is very similar to iOS native ActionSheet presentation style of a UIAlertController. As

Anatoliy Voropay 22 Dec 27, 2022
Drawer view controller that easy to use!

KWDrawerController Drawer view controller that is easy to use! Installation CocoaPods (iOS 8+ projects) KWDrawerController is available on CocoaPods.

Jungwon An 157 Jun 14, 2022