SkillAgentSearch skills...

LGSideMenuController

iOS view controller which manages left and right side views

Install / Use

/learn @Friend-LGA/LGSideMenuController

README

LGSideMenuController

iOS view controller which manages left and right side views.

Platform SwiftPM CocoaPods Carthage License

Preview

Presentation Style: Scale From Big

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/ScaleFromBig.gif" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/ScaleFromBig1.jpg" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/ScaleFromBig2.jpg" height="480"/>

Presentation Style: Slide Above Blurred

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/SlideAboveBlurred.gif" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/SlideAboveBlurred1.jpg" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/SlideAboveBlurred2.jpg" height="480"/>

Presentation Style: Slide Below Shifted

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/SlideBelowShifted.gif" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/SlideBelowShifted1.jpg" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/672f952ec7277d65982d65a104384cd3163749a4/LGSideMenuController/Preview/SlideBelowShifted2.jpg" height="480"/>

Presentation Style: Slide Aside + Usage: Inside UINavigationController

<img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/25ab622bbb345a7a41fc41aec71fb0ed83c0fc0d/LGSideMenuController/Preview/SlideAside_InsideNavVC.gif" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/25ab622bbb345a7a41fc41aec71fb0ed83c0fc0d/LGSideMenuController/Preview/SlideAside_InsideNavVC1.jpg" height="480"/> <img src="https://raw.githubusercontent.com/Friend-LGA/ReadmeFiles/25ab622bbb345a7a41fc41aec71fb0ed83c0fc0d/LGSideMenuController/Preview/SlideAside_InsideNavVC2.jpg" height="480"/>

Other presentation styles and examples of usage you can try in included demo projects. Also you can make your very own style, as they are highly customizable.

Installation

| LGSideMenuController Version | Min iOS Version | Language | |------------------------------|-----------------|-------------| | 1.0.0 - 1.0.10 | 6.0 | Objective-C | | 1.1.0 - 2.2.0 | 8.0 | Objective-C | | 2.3.0 | 9.0 | Objective-C | | 3.0.0 | 9.0 | Swift |

With Source Code

  1. Download repository
  2. Add LGSideMenuController directory to your project
  3. Enjoy!

With Swift Package Manager

Starting with Xcode 9.0 you can use built-in swift package manager, follow apple documentation. First supported version is 2.3.0.

With CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. To install with CocoaPods, follow the "Get Started" section on CocoaPods.

Podfile

platform :ios, '9.0'
use_frameworks!
pod 'LGSideMenuController'

Then import framework where you need to use the library:

import LGSideMenuController

With Carthage

Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods. To install with carthage, follow instructions on Carthage.

Cartfile

github "Friend-LGA/LGSideMenuController"

Then import framework where you need to use the library:

import LGSideMenuController

Usage

LGSideMenuController is inherited from UIViewController, so you can use it the same way as any other UIViewController.

First, you need to provide basic view controllers or views, which will be used to show root, left and right views.

  • rootViewController or rootView. This view controller or view will be used as the root view.
  • leftViewController or leftView. This view controller or view will be used as the left side view.
  • rightViewController or rightView. This view controller or view will be used as the right side view.
// You don't have to assign both: left and right side views. 
// Just one is enough, but you can use both if you want.
// UIViewController() and UIView() here are just as an example. 
// Use any UIViewController or UIView to assign, as you wish.

let sideMenuController = 
    LGSideMenuController(rootViewController: UIViewController(),
                         leftViewController: UIViewController(),
                         rightViewController: UIViewController())

// ===== OR =====

let sideMenuController = 
    LGSideMenuController(rootView: UIView(),
                         leftView: UIView(),
                         rightView: UIView())

// ===== OR =====

let sideMenuController = LGSideMenuController()
sideMenuController.rootViewController = UIViewController()
sideMenuController.leftViewController = UIViewController()
sideMenuController.rightViewController = UIViewController()

// ===== OR =====

let sideMenuController = LGSideMenuController()
sideMenuController.rootView = UIView()
sideMenuController.leftView = UIView()
sideMenuController.rightView = UIView()

Second, you probably want to choose presentation style, there are a few:

  • scaleFromBig. Side view is located below the root view and when appearing is changing its scale from large to normal. Root view also is going to be minimized and moved aside.
  • scaleFromLittle. Side view is located below the root view and when appearing is changing its scale from small to normal. Root view also is going to be minimized and moved aside.
  • slideAbove. Side view is located above the root view and when appearing is sliding from a side. Root view is staying still.
  • slideAboveBlurred. Side view is located above the root view and when appearing is sliding from a side. Root view is staying still. Side view has blurred background.
  • slideBelow. Side view is located below the root view. Root view is going to be moved aside.
  • slideBelowShifted. Side view is located below the root view. Root view is going to be moved aside. Also content of the side view has extra shifting.
  • slideAside. Side view is located at the same level as root view and when appearing is sliding from a side. Root view is going to be moved together with the side view.
sideMenuController.leftViewPresentationStyle = .slideAboveBlurred
sideMenuController.rightViewPresentationStyle = .slideBelowShifted

Third, you might want to change width of your side view. By default it's calculated as smallest side of the screen minus 44.0, then compare it to 320.0 and choose smallest number. Like so: min(min(UIScreen.main.bounds.width, UIScreen.main.bounds.height) - 44.0, 320.0).

sideMenuController.leftViewWidth = 250.0
sideMenuController.rightViewWidth = 100.0

To show/hide side views just use any of these and similar methods:

// ===== LEFT =====

/// Shows left side view.
func showLeftView()

/// Hides left side view.
func hideLeftView()

/// Toggle (shows/hides) left side view.
func toggleLeftView()

// ===== RIGHT =====

/// Shows right side view.
func showRightView()

/// Hides right side view.
func hideRightView()

/// Toggle (shows/hides) right side view.
func toggleRightView()

Quick Example

You don't have to create both: left and right side views. Just one is enough, but you can use both if you want. We create them here just as an example.

Without Storyboard

  1. Create root view controller (for example UINavigationController).
  2. Create left view controller (for example UITableViewController).
  3. Create right view controller (for example UITableViewController).
  4. Create instance of LGSideMenuController with these controllers.
  5. Configure.
// Simple AppDelegate.swift
// Just as an example. Don't take it as a strict approach.

import UIKit
import LGSideMenuController

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // 1. Create root view controller.
        // Here it is just simple `UINavigationController`.
        // Read apple documentation and google to create one:
        // https://developer.apple.com/documentation/uikit/uinavigationcontroller
        // https://google.com/search?q=uinavigationcon
View on GitHub
GitHub Stars2.1k
CategoryDevelopment
Updated8d ago
Forks331

Languages

Swift

Security Score

100/100

Audited on Mar 16, 2026

No findings