Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b6b8c446c | |||
| 175042e238 | |||
| 2a4d78b7fa | |||
| 8573045525 | |||
| 9e5b11c1cc | |||
| ecdbfbb11a | |||
| 5dc207396f | |||
| 67886c73a8 | |||
| cbc1ac6624 | |||
| 9c7111e7e3 | |||
| df48679df4 | |||
| f32cf72443 | |||
| b15180fb8a | |||
| 6eae7987ef | |||
| c6b7780daf | |||
| c54f364d49 | |||
| 5ac61bc981 | |||
| b647880794 | |||
| 2e684440fc | |||
| 6064d6d5fc | |||
| d13ed0ea9b | |||
| ef607b3ab2 | |||
| 069b974145 | |||
| 3e452b2a69 | |||
| 021fe8cd6a | |||
| fd6ecbbece | |||
| 313cda5d69 | |||
| e35a46b075 | |||
| 3702ecb770 | |||
| 893818b582 | |||
| f21ed8965d | |||
| db1cf2a6b6 |
@@ -16,6 +16,7 @@
|
||||
SideMenuManager.menuAddScreenEdgePanGesturesToPresent(toView: self.navigationController!.view)
|
||||
*/
|
||||
|
||||
@objcMembers
|
||||
open class SideMenuManager : NSObject {
|
||||
|
||||
@objc public enum MenuPushStyle : Int {
|
||||
@@ -132,6 +133,14 @@ open class SideMenuManager : NSObject {
|
||||
|
||||
/// Default instance of SideMenuManager.
|
||||
open static let `default` = SideMenuManager()
|
||||
|
||||
/// Default instance of SideMenuManager (objective-C).
|
||||
open class var defaultManager: SideMenuManager {
|
||||
get {
|
||||
return SideMenuManager.default
|
||||
}
|
||||
}
|
||||
|
||||
internal var transition: SideMenuTransition!
|
||||
|
||||
public override init() {
|
||||
@@ -244,6 +253,7 @@ open class SideMenuManager : NSObject {
|
||||
|
||||
if menuEnableSwipeGestures {
|
||||
let exitPanGesture = UIPanGestureRecognizer()
|
||||
exitPanGesture.cancelsTouchesInView = false
|
||||
forMenu.view.addGestureRecognizer(exitPanGesture)
|
||||
if leftSide {
|
||||
menuLeftSwipeToDismissGesture = exitPanGesture
|
||||
|
||||
@@ -7,21 +7,14 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
public protocol UISideMenuNavigationControllerDelegate: class {
|
||||
func sideMenuWillAppear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
func sideMenuDidAppear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
func sideMenuWillDisappear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
func sideMenuDidDisappear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
}
|
||||
|
||||
// This makes adherance to the protocol optional:
|
||||
extension UIViewController {
|
||||
func sideMenuWillAppear(menu: UISideMenuNavigationController, animated: Bool) {}
|
||||
func sideMenuDidAppear(menu: UISideMenuNavigationController, animated: Bool) {}
|
||||
func sideMenuWillDisappear(menu: UISideMenuNavigationController, animated: Bool) {}
|
||||
func sideMenuDidDisappear(menu: UISideMenuNavigationController, animated: Bool) {}
|
||||
@objc public protocol UISideMenuNavigationControllerDelegate {
|
||||
@objc optional func sideMenuWillAppear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
@objc optional func sideMenuDidAppear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
@objc optional func sideMenuWillDisappear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
@objc optional func sideMenuDidDisappear(menu: UISideMenuNavigationController, animated: Bool)
|
||||
}
|
||||
|
||||
@objcMembers
|
||||
open class UISideMenuNavigationController: UINavigationController {
|
||||
|
||||
fileprivate weak var foundDelegate: UISideMenuNavigationControllerDelegate?
|
||||
@@ -56,7 +49,9 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
return sideMenuManager.transition
|
||||
}
|
||||
}
|
||||
weak var sideMenuDelegate: UISideMenuNavigationControllerDelegate?
|
||||
|
||||
/// Delegate for receiving appear and disappear related events. If `nil` the visible view controller that displays a `UISideMenuNavigationController` automatically receives these events.
|
||||
open weak var sideMenuDelegate: UISideMenuNavigationControllerDelegate?
|
||||
|
||||
/// SideMenuManager instance associated with this menu. Default is `SideMenuManager.default`. This property cannot be changed after the menu has loaded.
|
||||
open weak var sideMenuManager: SideMenuManager! = SideMenuManager.default {
|
||||
@@ -104,6 +99,14 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
fatalError("init is not available")
|
||||
}
|
||||
|
||||
public override init(rootViewController: UIViewController) {
|
||||
super.init(rootViewController: rootViewController)
|
||||
}
|
||||
|
||||
public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
}
|
||||
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
}
|
||||
@@ -134,7 +137,7 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
presentingViewController?.view.endEditing(true)
|
||||
|
||||
foundDelegate = nil
|
||||
activeDelegate?.sideMenuWillAppear(menu: self, animated: animated)
|
||||
activeDelegate?.sideMenuWillAppear?(menu: self, animated: animated)
|
||||
}
|
||||
|
||||
override open func viewDidAppear(_ animated: Bool) {
|
||||
@@ -150,7 +153,7 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
return
|
||||
}
|
||||
|
||||
activeDelegate?.sideMenuDidAppear(menu: self, animated: animated)
|
||||
activeDelegate?.sideMenuDidAppear?(menu: self, animated: animated)
|
||||
|
||||
#if !STFU_SIDEMENU
|
||||
if topViewController == nil {
|
||||
@@ -190,16 +193,16 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
options: sideMenuManager.menuAnimationOptions,
|
||||
animations: {
|
||||
self.transition.hideMenuStart()
|
||||
self.activeDelegate?.sideMenuWillDisappear(menu: self, animated: animated)
|
||||
self.activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
}) { (finished) -> Void in
|
||||
self.activeDelegate?.sideMenuDidDisappear(menu: self, animated: animated)
|
||||
self.activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
self.view.isHidden = true
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
activeDelegate?.sideMenuWillDisappear(menu: self, animated: animated)
|
||||
activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
}
|
||||
|
||||
override open func viewDidDisappear(_ animated: Bool) {
|
||||
@@ -213,7 +216,7 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
transition.hideMenuStart().hideMenuComplete()
|
||||
}
|
||||
|
||||
activeDelegate?.sideMenuDidDisappear(menu: self, animated: animated)
|
||||
activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
|
||||
// Clear selecton on UITableViewControllers when reappearing using custom transitions
|
||||
guard let tableViewController = topViewController as? UITableViewController,
|
||||
@@ -270,7 +273,7 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
let animated = animated || sideMenuManager.menuAlwaysAnimate
|
||||
|
||||
CATransaction.setCompletionBlock( { () -> Void in
|
||||
activeDelegate?.sideMenuDidDisappear(menu: self, animated: animated)
|
||||
activeDelegate?.sideMenuDidDisappear?(menu: self, animated: animated)
|
||||
if !animated {
|
||||
self.transition.hideMenuStart().hideMenuComplete()
|
||||
}
|
||||
@@ -286,7 +289,7 @@ open class UISideMenuNavigationController: UINavigationController {
|
||||
initialSpringVelocity: sideMenuManager.menuAnimationInitialSpringVelocity,
|
||||
options: sideMenuManager.menuAnimationOptions,
|
||||
animations: {
|
||||
activeDelegate?.sideMenuWillDisappear(menu: self, animated: animated)
|
||||
activeDelegate?.sideMenuWillDisappear?(menu: self, animated: animated)
|
||||
self.transition.hideMenuStart()
|
||||
})
|
||||
UIView.setAnimationsEnabled(areAnimationsEnabled)
|
||||
|
||||
@@ -1,37 +1,59 @@
|
||||
# ▤ SideMenu
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
|
||||
### If you like SideMenu, give it a ★ at the top right of its [GitHub](https://github.com/jonkykong/SideMenu) page.
|
||||
### If you like SideMenu, give it a ★ at the top right of this page.
|
||||
#### Using SideMenu in your app? [Send](mailto:yo@massappeal.co?subject=SideMenu%20in%20action!) me a link to your app in the app store!
|
||||
|
||||
> Hi, I'm Jon Kent and I am an iOS designer, developer, and mobile strategist. I love coffee and play the drums.
|
||||
> * [**Hire me**](mailto:yo@massappeal.co?subject=Let's%20build%20something%20amazing) to help you make cool stuff. *Note: If you're having a problem with SideMenu, please open an [issue](https://github.com/jonkykong/SideMenu/issues/new) and do not email me.*
|
||||
> * Check out my [website](http://massappeal.co) to see some of my other projects.
|
||||
> * Building and maintaining this free library takes time. Help keep me awake and buy me a coffee ☕️ via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=contact%40jonkent%2eme&lc=US¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted).
|
||||
> * Building and maintaining this **free** library takes a lot of my time and **saves you time**. Please consider paying it forward by supporting me with a small amount to my [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=contact%40jonkent%2eme&lc=US¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted). (only **2** people have donated since inception 😕 but **thank you** to those who have!)
|
||||
|
||||
* **[Overview](#overview)**
|
||||
* [Preview Samples](#preview-samples)
|
||||
* **[Requirements](#requirements)**
|
||||
* **[Installation](#installation)**
|
||||
* [CocoaPods](#cocoapods)
|
||||
* [Carthage](#carthage)
|
||||
* **[Usage](#usage)**
|
||||
* [Code-less Storyboard Implementation](#code-less-storyboard-implementation)
|
||||
* [Code Implementation](#code-implementation)
|
||||
* **[Customization](#customization)**
|
||||
* [SideMenuManager](#sidemenumanager)
|
||||
* [UISideMenuNavigationController](#uisidemenunavigationcontroller)
|
||||
* [UISideMenuNavigationControllerDelegate](#uisidemenunavigationcontrollerdelegate)
|
||||
* [Advanced](#advanced)
|
||||
* [Known Issues](#known-issues)
|
||||
* [Thank You](#thank-you)
|
||||
* [License](#license)
|
||||
|
||||
## Overview
|
||||
|
||||
SideMenu is a simple and versatile side menu control written in Swift.
|
||||
- [x] **It can be implemented in storyboard without a single line of [code](#code-less-storyboard-implementation).**
|
||||
- [x] Four standard animation styles to choose from (there's even a parallax effect if you want to get weird).
|
||||
- [x] Highly customizable without needing to write tons of custom code.
|
||||
- [x] Supports continuous swiping between side menus on boths sides in a single gesture.
|
||||
- [x] Global menu configuration. Set-up once and be done for all screens.
|
||||
- [x] Menus can be presented and dismissed the same as any other view controller since this control uses [custom transitions](https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/CustomizingtheTransitionAnimations.html).
|
||||
- [x] Animations use your view controllers, not snapshots.
|
||||
- [x] Properly handles screen rotation and in-call status bar height changes.
|
||||
* **It can be implemented in storyboard without a single line of [code](#code-less-storyboard-implementation).**
|
||||
* Four standard animation styles to choose from (there's even a parallax effect if you want to get weird).
|
||||
* Highly customizable without needing to write tons of custom code.
|
||||
* Supports continuous swiping between side menus on boths sides in a single gesture.
|
||||
* Global menu configuration. Set-up once and be done for all screens.
|
||||
* Menus can be presented and dismissed the same as any other view controller since this control uses [custom transitions](https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/CustomizingtheTransitionAnimations.html).
|
||||
* Animations use your view controllers, not snapshots.
|
||||
* Properly handles screen rotation and in-call status bar height changes.
|
||||
|
||||
Check out the example project to see it in action!
|
||||
### Preview Samples
|
||||
| Slide Out | Slide In | Dissolve | Slide In + Out |
|
||||
| --- | --- | --- | --- |
|
||||
|  |  |  |  |
|
||||
|  |  |  |  |
|
||||
|
||||
## Requirements
|
||||
- [x] iOS 8 or higher.
|
||||
* Xcode 9.
|
||||
* iOS 8 or higher.
|
||||
|
||||
## Installation
|
||||
### CocoaPods
|
||||
@@ -81,13 +103,13 @@ github "jonkykong/SideMenu" "master"
|
||||
## Usage
|
||||
### Code-less Storyboard Implementation
|
||||
1. Create a Navigation Controller for a side menu. Set the `Custom Class` of the Navigation Controller to be `UISideMenuNavigationController` in the **Identity Inspector**. Set the `Module` to `SideMenu` (ignore this step if you've manually added SideMenu to your project). Create a Root View Controller for the Navigation Controller (shown as a UITableViewController below). Set up any Triggered Segues you want in that view controller.
|
||||

|
||||

|
||||
|
||||
2. Set the `Left Side` property of the `UISideMenuNavigationController` to On if you want it to appear from the left side of the screen, or Off/Default if you want it to appear from the right side.
|
||||

|
||||

|
||||
|
||||
3. Add a UIButton or UIBarButton to a view controller that you want to display the menu from. Set that button's Triggered Segues action to modally present the Navigation Controller from step 1.
|
||||

|
||||

|
||||
|
||||
That's it. *Note: you can only enable gestures in code.*
|
||||
### Code Implementation
|
||||
@@ -126,7 +148,7 @@ dismiss(animated: true, completion: nil)
|
||||
That's it.
|
||||
### Customization
|
||||
#### SideMenuManager
|
||||
Just type ` SideMenuManager.default.menu...` and code completion will show you everything you can customize (defaults are shown below for reference):
|
||||
Just type ` SideMenuManager.default.menu...` and code completion will show you everything you can customize (for Objective-C, use `SideMenuManager.defaultManager.menu...`). Defaults values are shown below for reference:
|
||||
``` swift
|
||||
/**
|
||||
The push style of the menu.
|
||||
@@ -136,7 +158,7 @@ There are six modes in MenuPushStyle:
|
||||
- popWhenPossible: If a view controller already in the stack is of the same class as the pushed view controller, the stack is instead popped back to the existing view controller. This behavior can help users from getting lost in a deep navigation stack.
|
||||
- preserve: If a view controller already in the stack is of the same class as the pushed view controller, the existing view controller is pushed to the end of the stack. This behavior is similar to a UITabBarController.
|
||||
- preserveAndHideBackButton: Same as .preserve and back buttons are automatically hidden.
|
||||
- replace: Any existing view controllers are released from the stack and replaced with the pushed view controller. Back buttons are automatically hidden. This behavior is ideal if view controllers require a lot of memory or their state doesn't need to be preserved..
|
||||
- replace: Any existing view controllers are released from the stack and replaced with the pushed view controller. Back buttons are automatically hidden. This behavior is ideal if view controllers require a lot of memory or their state doesn't need to be preserved.
|
||||
- subMenu: Unlike all other behaviors that push using the menu's presentingViewController, this behavior pushes view controllers within the menu. Use this behavior if you want to display a sub menu.
|
||||
*/
|
||||
open var menuPushStyle: MenuPushStyle = .defaultBehavior
|
||||
@@ -224,8 +246,8 @@ of the view controller being presented in storyboard or during its initalization
|
||||
*/
|
||||
open var menuDismissOnPush = true
|
||||
|
||||
/// Uses the menu dismiss animation even if pushing a view is not animated itself.
|
||||
open var menuAnimateDismissOnNonAnimatedPush = false
|
||||
/// Forces menus to always animate when appearing or disappearing, regardless of a pushed view controller's animation.
|
||||
open var menuAlwaysAnimate = false
|
||||
|
||||
/**
|
||||
The blur effect style of the menu if the menu's root view controller is a UITableViewController or UICollectionViewController.
|
||||
@@ -297,7 +319,7 @@ extension MyViewController: UISideMenuNavigationControllerDelegate {
|
||||
|
||||
}
|
||||
```
|
||||
*Note: there is no `delegate` property to set on the `UISideMenuNavigationController` for this to work. If your view controller adheres to the protocol then the methods will be called automatically.*
|
||||
*Note: setting the `sideMenuDelegate` property on `UISideMenuNavigationController` is optional. If your view controller adheres to the protocol then the methods will be called automatically.*
|
||||
### Advanced
|
||||
For simplicity, `SideMenuManager.default` serves as the primary instance as most projects will only need one menu across all screens. If you need to show a different SideMenu, such as from a modal view controller presented from a previous SideMenu, do the following:
|
||||
1. Declare a variable containing your custom `SideMenuManager` instance. You may want it to define it globally and configure it in your app delegate if menus will be used on multiple screens.
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SideMenu"
|
||||
s.version = "3.1.2"
|
||||
s.version = "3.1.5"
|
||||
s.summary = "Simple side menu control for iOS in Swift inspired by Facebook. Right and Left sides. No coding required."
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
|
||||
Reference in New Issue
Block a user