iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.
iOS Slide View based on iQON, Feedly, Google+, Ameba iPhone app.
pod 'SlideMenuControllerSwift'
if iOS8 or later, Carthage is supported
github "dekatotoro/SlideMenuControllerSwift"
to your Cartfile.carthage update
.for more info, see Carthage
Add the SlideMenuController.swift
file to your project.
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
}
SlideMenuController
and put UIViewController in a storyboard.awakeFromNib
, then instantiate any view controllersclass 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
...
self.slideMenuController()?
or
if let slideMenuController = self.slideMenuController() {
// some code
}
viewController.addLeftBarButtonWithImage(UIImage(named: "hoge")!)
viewController.addRightBarButtonWithImage(UIImage(named: "fuga")!)
// Open
self.slideMenuController()?.openLeft()
self.slideMenuController()?.openRight()
// close
self.slideMenuController()?.closeLeft()
self.slideMenuController()?.closeRight()
SlideMenuControllerDelegate
use this:func leftWillOpen()
func leftDidOpen()
func leftWillClose()
func leftDidClose()
func rightWillOpen()
func rightDidOpen()
func rightWillClose()
func rightDidClose()
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.
Forks, patches and other feedback are welcome.
SlideMenuControllerSwift is available under the MIT license. See the LICENSE file for more info.