From 7512cb93739cea02ed5978378a5efa43046f753a Mon Sep 17 00:00:00 2001 From: jonkykong Date: Tue, 11 Apr 2017 03:35:54 -0700 Subject: [PATCH 1/5] Fix for disabling gestures. Gestures were being added multiple times preventing all of them from being disabled when the menuEnableSwipeGestures was used. --- Pod/Classes/SideMenuManager.swift | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Pod/Classes/SideMenuManager.swift b/Pod/Classes/SideMenuManager.swift index 518fd5c..5e7482a 100644 --- a/Pod/Classes/SideMenuManager.swift +++ b/Pod/Classes/SideMenuManager.swift @@ -97,12 +97,6 @@ open class SideMenuManager : NSObject { /// The radius of the shadow around the menu view controller or existing view controller depending on the `menuPresentMode`. Default is 5. open static var menuShadowRadius: CGFloat = 5 - /// The left menu swipe to dismiss gesture. - open static weak var menuLeftSwipeToDismissGesture: UIPanGestureRecognizer? - - /// The right menu swipe to dismiss gesture. - open static weak var menuRightSwipeToDismissGesture: UIPanGestureRecognizer? - /// Enable or disable interaction with the presenting view controller while the menu is displayed. Enabling may make it difficult to dismiss the menu or cause exceptions if the user tries to present and already presented menu. Default is false. open static var menuPresentingViewControllerUserInteractionEnabled: Bool = false @@ -221,6 +215,30 @@ open class SideMenuManager : NSObject { } } + /// The left menu swipe to dismiss gesture. + open static weak var menuLeftSwipeToDismissGesture: UIPanGestureRecognizer? { + didSet { + oldValue?.view?.removeGestureRecognizer(oldValue!) + setupGesture(gesture: menuLeftSwipeToDismissGesture) + } + } + + /// The right menu swipe to dismiss gesture. + open static weak var menuRightSwipeToDismissGesture: UIPanGestureRecognizer? { + didSet { + oldValue?.view?.removeGestureRecognizer(oldValue!) + setupGesture(gesture: menuRightSwipeToDismissGesture) + } + } + + fileprivate class func setupGesture(gesture: UIPanGestureRecognizer?) { + guard let gesture = gesture else { + return + } + + gesture.addTarget(SideMenuTransition.self, action:#selector(SideMenuTransition.handleHideMenuPan(_:))) + } + fileprivate class func setupNavigationController(_ forMenu: UISideMenuNavigationController?, leftSide: Bool) { guard let forMenu = forMenu else { return @@ -228,7 +246,6 @@ open class SideMenuManager : NSObject { if menuEnableSwipeGestures { let exitPanGesture = UIPanGestureRecognizer() - exitPanGesture.addTarget(SideMenuTransition.self, action:#selector(SideMenuTransition.handleHideMenuPan(_:))) forMenu.view.addGestureRecognizer(exitPanGesture) if leftSide { menuLeftSwipeToDismissGesture = exitPanGesture From 2878eea03f8c09fa3aa8c53d4c8867e5bb16431c Mon Sep 17 00:00:00 2001 From: jonkykong Date: Tue, 11 Apr 2017 03:40:28 -0700 Subject: [PATCH 2/5] Subtle tweak if a larger transform is used on the main view controller when menu is presented (edge case). --- Pod/Classes/SideMenuTransition.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Pod/Classes/SideMenuTransition.swift b/Pod/Classes/SideMenuTransition.swift index 1d32fec..fcf0141 100644 --- a/Pod/Classes/SideMenuTransition.swift +++ b/Pod/Classes/SideMenuTransition.swift @@ -304,6 +304,8 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition { if statusBarOffset >= CGFloat.ulpOfOne { statusBarFrame.size.height = statusBarOffset } + SideMenuTransition.tapView?.transform = .identity + SideMenuTransition.tapView?.bounds = mainViewController.view.bounds SideMenuTransition.statusBarView?.frame = statusBarFrame SideMenuTransition.statusBarView?.alpha = 1 @@ -329,6 +331,9 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition { if SideMenuManager.menuPresentMode != .viewSlideOut { mainViewController.view.transform = CGAffineTransform(scaleX: SideMenuManager.menuAnimationTransformScaleFactor, y: SideMenuManager.menuAnimationTransformScaleFactor) + if SideMenuManager.menuAnimationTransformScaleFactor > 1 { + SideMenuTransition.tapView?.transform = mainViewController.view.transform + } mainViewController.view.alpha = 1 - SideMenuManager.menuAnimationFadeStrength } } @@ -478,6 +483,9 @@ extension SideMenuTransition: UIViewControllerAnimatedTransitioning { container.insertSubview(tapView, aboveSubview: topView) tapView.bounds = container.bounds tapView.center = topView.center + if SideMenuManager.menuAnimationTransformScaleFactor > 1 { + tapView.transform = topView.transform + } SideMenuTransition.tapView = tapView } if let statusBarView = SideMenuTransition.statusBarView { From 8bb2505b6f9584a72ad5244f8dc608e18fe29444 Mon Sep 17 00:00:00 2001 From: jonkykong Date: Tue, 11 Apr 2017 03:41:13 -0700 Subject: [PATCH 3/5] Reverting old logic that kept the layout correct when presenting a sub-screen. --- .../UISideMenuNavigationController.swift | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Pod/Classes/UISideMenuNavigationController.swift b/Pod/Classes/UISideMenuNavigationController.swift index 4d0f542..48e5761 100644 --- a/Pod/Classes/UISideMenuNavigationController.swift +++ b/Pod/Classes/UISideMenuNavigationController.swift @@ -66,6 +66,27 @@ open class UISideMenuNavigationController: UINavigationController { } } + override open func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + + // when presenting a view controller from the menu, the menu view gets moved into another transition view above our transition container + // which can break the visual layout we had before. So, we move the menu view back to its original transition view to preserve it. + if !isBeingDismissed { + if let mainView = presentingViewController?.view { + switch SideMenuManager.menuPresentMode { + case .viewSlideOut, .viewSlideInOut: + mainView.superview?.insertSubview(view, belowSubview: mainView) + case .menuSlideIn, .menuDissolveIn: + if let tapView = SideMenuTransition.tapView { + mainView.superview?.insertSubview(view, aboveSubview: tapView) + } else { + mainView.superview?.insertSubview(view, aboveSubview: mainView) + } + } + } + } + } + override open func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) From dda720eee742c5fe8f21065c98dac8e3cc93d46b Mon Sep 17 00:00:00 2001 From: jonkykong Date: Tue, 11 Apr 2017 03:41:51 -0700 Subject: [PATCH 4/5] Updated project settings. --- SideMenu.xcodeproj/project.pbxproj | 2 +- SideMenu.xcodeproj/xcshareddata/xcschemes/SideMenu.xcscheme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SideMenu.xcodeproj/project.pbxproj b/SideMenu.xcodeproj/project.pbxproj index 0289d40..591e846 100644 --- a/SideMenu.xcodeproj/project.pbxproj +++ b/SideMenu.xcodeproj/project.pbxproj @@ -279,7 +279,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = jonkykong; TargetAttributes = { 7B48A0D21DCB2487002990A1 = { diff --git a/SideMenu.xcodeproj/xcshareddata/xcschemes/SideMenu.xcscheme b/SideMenu.xcodeproj/xcshareddata/xcschemes/SideMenu.xcscheme index ddb1da7..68e86a1 100644 --- a/SideMenu.xcodeproj/xcshareddata/xcschemes/SideMenu.xcscheme +++ b/SideMenu.xcodeproj/xcshareddata/xcschemes/SideMenu.xcscheme @@ -1,6 +1,6 @@ Date: Tue, 11 Apr 2017 03:44:32 -0700 Subject: [PATCH 5/5] Updated pod spec and README for Cocoapods. --- README.md | 20 ++++++++++---------- SideMenu.podspec | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index af52526..a69273f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![License](https://img.shields.io/cocoapods/l/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu) [![Platform](https://img.shields.io/cocoapods/p/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu) -### If you like SideMenu, give it a ★ at the top right of this page. +### If you like SideMenu, give it a ★ at the top right of its [GitHub](https://github.com/jonkykong/SideMenu) page. #### Using SideMenu in your app? [Send](mailto:contact@jonkent.me?subject=SideMenu+in+action!) me a link to your app in the app store! > I'm Jon Kent and I freelance iOS design, development, and mobile strategies. I love coffee and play the drums. @@ -15,14 +15,14 @@ ## 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 @@ -31,7 +31,7 @@ Check out the example project to see it in action! | ![](etc/SlideOut.gif) | ![](etc/SlideIn.gif) | ![](etc/Dissolve.gif) | ![](etc/InOut.gif) | ## Requirements -- [x] iOS 8 or higher +* iOS 8 or higher ## Installation ### CocoaPods diff --git a/SideMenu.podspec b/SideMenu.podspec index 09bbbf8..d62ab0c 100644 --- a/SideMenu.podspec +++ b/SideMenu.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "SideMenu" - s.version = "2.3.0" + s.version = "2.3.1" 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.