Google styled side panel for iOS written in Swift
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Assets Add demo Jul 7, 2016
Example Update swift version Sep 14, 2017
Resources Initial commit Jun 30, 2016
SidePanel.xcodeproj Update swift version Sep 14, 2017
SidePanel.xcworkspace Xcode update Sep 5, 2017
SidePanel/0.1.0
Source Migrate to swift 3 Sep 3, 2017
Tests Initial commit Jun 30, 2016
.gitignore
.swift-version Update swift version Sep 14, 2017
.travis.yml Initial commit Jun 30, 2016
CODE_OF_CONDUCT.md Initial commit Jun 30, 2016
LICENSE Initial commit Jun 30, 2016
README.md
SidePanel.podspec

README.md

SidePanel

CI Status Version License Platform Carthage compatible

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 9.0+
  • Xcode 8.3+
  • Swift 3.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To 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 install

Carthage

Carthage 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 carthage

To 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.

Usage

//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
    }
  }
}

Author

Dushyant Bansal, dushyant37@gmail.com

License

SidePanel is available under the MIT license. See the LICENSE file for more info.