To run the example project, clone the repo, and run pod install from the Example directory first.
- iOS 9.0+
- Xcode 8.3+
- Swift 3.0+
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapodsTo integrate SidePanel into your Xcode project using CocoaPods, specify it in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'SidePanel'Then, run the following command:
$ pod installCarthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthageTo integrate SidePanel into your Xcode project using Carthage, specify it in your Cartfile:
github "db42/SidePanel" ~> 0.6.1
Run carthage update to build the framework and drag the built SidePanel.framework into your Xcode project.
//Override SidePanelController to provide a custom hamburger menu icon
class MySidePanelController: SidePanelController {
override func leftButton() -> UIButton {
let frame = CGRectMake(0, 0, 20, 20)
let button = UIButton(frame: frame)
button.setImage(UIImage(named: "menu"), forState: .Normal)
return button
}
}
//Initialise SidePanelController - AppDelegate.swift
var sidePanelController: SidePanelController?
var mainVC1: UINavigationController?
var mainVC2: UINavigationController?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
....
let mainVC1 = MainViewController()
let sc = SideController()
let sidePanelController = MySidePanelController(sideController: sc)
sidePanelController.selectedViewController = mainVC1
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = svc
self.window?.makeKeyAndVisible()
self.sidePanelController = sidePanelController
....
}
//Handle navigation from SideController - SideViewController.swift
class SideViewController: UITableViewController {
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if let appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate {
let vc = indexPath.row == 0 ? appDelegate.mainVC1 : appDelegate.mainVC2
appDelegate.sidePanelController?.selectedViewController = vc
}
}
}Dushyant Bansal, dushyant37@gmail.com
SidePanel is available under the MIT license. See the LICENSE file for more info.
