SlideMenuControllerSwift
  • November 26, 2023

iOS Slide View based on iQON, Feedly, Google+, Ameba iPhone app.

Installation


CocoaPods

 

pod ‘SlideMenuControllerSwift’

Carthage

if iOS8 or later, Carthage is supported

  • Add github "dekatotoro/SlideMenuControllerSwift" to your Cartfile.
  • Run carthage update.

for more info, see Carthage

Manually

Add the SlideMenuController.swift file to your project.

Usage


Setup

Add import SlideMenuControllerSwift in your file

In your app delegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

// create viewController code…

let slideMenuController = SlideMenuController(mainViewController: mainViewController, leftMenuViewController: leftViewController, rightMenuViewController: rightViewController)
self.window?.rootViewController = slideMenuController
self.window?.makeKeyAndVisible()

return true
}

Storyboard Support
  1. Inherit SlideMenuController and put UIViewController in a storyboard.
  2. Override awakeFromNib, then instantiate any view controllers

class ContainerViewController: SlideMenuController {

override func awakeFromNib() {
if let controller = self.storyboard?.instantiateViewControllerWithIdentifier(“Main”) {
self.mainViewController = controller
}
if let controller = self.storyboard?.instantiateViewControllerWithIdentifier(“Left”) {
self.leftViewController = controller
}
super.awakeFromNib()
}

}

If you want to use the custom option, please set them before calling the init method, like so:

SlideMenuOptions.leftViewWidth = 50
SlideMenuOptions.contentViewScale = .50

You can access from UIViewController

 

self.slideMenuController()?

or

if let slideMenuController = self.slideMenuController() {
// some code
}

add navigationBarButton

viewController.addLeftBarButtonWithImage(UIImage(named: “hoge”)!)
viewController.addRightBarButtonWithImage(UIImage(named: “fuga”)!)

open and close

// Open
self.slideMenuController()?.openLeft()
self.slideMenuController()?.openRight()

// close
self.slideMenuController()?.closeLeft()
self.slideMenuController()?.closeRight()

monitor the state of menu, you can use SlideMenuControllerDelegate use this:

func leftWillOpen()
func leftDidOpen()
func leftWillClose()
func leftDidClose()
func rightWillOpen()
func rightDidOpen()
func rightWillClose()
func rightDidClose()

Requirements


Requires Swift4.0 and iOS 9.0 and ARC. If you are developing in the Swift1.1 ~ 3.2, please use branch of swift1.1 ~ 3.
If you want to use even iOS8.0, please to import the code directly.
If you want to use objective-c even iOS6.0, plesea use SlideMenuControllerOC.

Features


  • Highly customizable
  • Complete example

GitHub


View Github

#delegate #ios #slidemenu #storyboard #swift #uiviewcontroller
YOU MIGHT ALSO LIKE...
ConfettiView

A SwiftUI View that emits confetti with user-defined shapes, images, and text.

SwiftUI Colour Wheel

A colour wheel made all in SwiftUI. There are 2 different colour wheels to choose from. The first main one ...

ColorPickerRing

A color picker implementation with color wheel appearance written in plain SwiftUI. It is compatible with UIColor and NSColor.

ASCollectionView

This repository is no longer maintained. Here's why: with the release of iOS 16 SwiftUI now enables most of the ...