iOS Sliding Menu using Swift, based on the Gmail app using sliding menu.
pod 'TQSlidingMenuSwift'
####Manually Drag TQPresentationController.swift, TQBaseViewController.swift, TQMenuController.swift to your app. Extend your presenting view controllers from TQBaseViewController, and the menu view controller from TQMenuController That's it. Play with your Sliding Menu now!!!.
Add import TQSlidingMenuSwift
in your file
- Embed the first view controller in navigation controller, and derive it from TQBaseViewController.
- Create Menu Table View controller class, and add the same in story board, and derive it from TQMenuController. (Do not forget to re-name the class of tableview controller in storyboard to custom tableview controller class you just created).
- Set storyboard identifiers for all the view controllers to be displayed by sliding menu.
- Call setNavigtionMenu(...) method in viewDidLoad() method of every view controller that needs to be displayed.
setNavigtionMenu(withScreenTitle: "Google", withMenuControllerId: "menuVC")
- In Menu Table View Controller created by you, add the below code for when user select a row :
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row {
case 0:
performCustomSegue(withIdentifier: "VC1")
case 1:
performCustomSegue(withIdentifier: "VC2")
default:
performCustomSegue(withIdentifier: "VC1")
}
dismiss(animated: true, completion: nil)
}
Provide the storyboard id of view controllers to be presented
Contributers can fork the repo and provide useful features that can be integrated in it.
Requires Swift version > 3.0