Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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() {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -31,6 +31,8 @@ Check out the example project to see it in action!
|
||||
|  |  |  |  |
|
||||
|
||||
## Requirements
|
||||
- [x] Xcode 9.
|
||||
- [x] Swift 4.
|
||||
- [x] iOS 8 or higher.
|
||||
|
||||
## Installation
|
||||
@@ -126,7 +128,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.
|
||||
@@ -224,8 +226,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 +299,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