Compare commits
12 Commits
3.1.5
..
#258-Fixes
| Author | SHA1 | Date | |
|---|---|---|---|
| 99ea9bb9ad | |||
| 55776b4f9c | |||
| 1b6b8c446c | |||
| 175042e238 | |||
| 2a4d78b7fa | |||
| 8573045525 | |||
| 9e5b11c1cc | |||
| ecdbfbb11a | |||
| 5dc207396f | |||
| 67886c73a8 | |||
| cbc1ac6624 | |||
| 9c7111e7e3 |
@@ -253,6 +253,7 @@ open class SideMenuManager : NSObject {
|
||||
|
||||
if menuEnableSwipeGestures {
|
||||
let exitPanGesture = UIPanGestureRecognizer()
|
||||
exitPanGesture.cancelsTouchesInView = false
|
||||
forMenu.view.addGestureRecognizer(exitPanGesture)
|
||||
if leftSide {
|
||||
menuLeftSwipeToDismissGesture = exitPanGesture
|
||||
|
||||
@@ -125,10 +125,10 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
return
|
||||
}
|
||||
|
||||
let transform = view.transform
|
||||
view.transform = .identity
|
||||
let transform = view.layer.transform
|
||||
view.layer.transform = CATransform3DIdentity
|
||||
let translation = pan.translation(in: pan.view!)
|
||||
view.transform = transform
|
||||
view.layer.transform = transform
|
||||
|
||||
// do some math to translate this to a percentage based value
|
||||
if !interactive {
|
||||
@@ -166,9 +166,9 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
}
|
||||
default:
|
||||
interactive = false
|
||||
view.transform = .identity
|
||||
view.layer.transform = CATransform3DIdentity
|
||||
let velocity = pan.velocity(in: pan.view!).x * direction
|
||||
view.transform = transform
|
||||
view.layer.transform = transform
|
||||
if velocity >= 100 || velocity >= -50 && abs(distance) >= 0.5 {
|
||||
// bug workaround: animation briefly resets after call to finishInteractiveTransition() but before animateTransition completion is called.
|
||||
if ProcessInfo().operatingSystemVersion.majorVersion == 8 && percentComplete > 1 - CGFloat.ulpOfOne {
|
||||
@@ -226,10 +226,10 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
let menuView = menuViewController?.view
|
||||
let mainView = mainViewController?.view
|
||||
|
||||
mainView?.transform = .identity
|
||||
mainView?.layer.transform = CATransform3DIdentity
|
||||
mainView?.alpha = 1
|
||||
mainView?.frame.origin = .zero
|
||||
menuView?.transform = .identity
|
||||
menuView?.layer.transform = CATransform3DIdentity
|
||||
menuView?.frame.origin.y = 0
|
||||
menuView?.frame.size.width = menuWidth
|
||||
menuView?.frame.size.height = mainView?.frame.height ?? 0 // in case status bar height changed
|
||||
@@ -248,7 +248,11 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
case .viewSlideOut:
|
||||
menuView?.alpha = 1 - sideMenuManager.menuAnimationFadeStrength
|
||||
menuView?.frame.origin.x = presentDirection == .left ? 0 : (mainView?.frame.width ?? 0) - menuWidth
|
||||
menuView?.transform = CGAffineTransform(scaleX: sideMenuManager.menuAnimationTransformScaleFactor, y: sideMenuManager.menuAnimationTransformScaleFactor)
|
||||
let f = sideMenuManager.menuAnimationTransformScaleFactor
|
||||
menuView?.layer.transform = CATransform3D(m11: f, m12: 0, m13: 0, m14: 0,
|
||||
m21: 0, m22: f, m23: 0, m24: 0,
|
||||
m31: 0, m32: 0, m33: 1, m34: 0,
|
||||
m41: 0, m42: 0, m43: 0, m44: 1)
|
||||
|
||||
case .viewSlideInOut:
|
||||
menuView?.alpha = 1
|
||||
@@ -295,11 +299,11 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
let mainView = mainViewController?.view
|
||||
|
||||
menuView?.alpha = 1
|
||||
menuView?.transform = .identity
|
||||
menuView?.layer.transform = CATransform3DIdentity
|
||||
menuView?.frame.size.width = menuWidth
|
||||
let size = SideMenuManager.appScreenRect.size
|
||||
menuView?.frame.origin.x = presentDirection == .left ? 0 : size.width - menuWidth
|
||||
mainView?.transform = .identity
|
||||
mainView?.layer.transform = CATransform3DIdentity
|
||||
mainView?.frame.size.width = size.width
|
||||
let statusBarOffset = size.height - (menuView?.bounds.height ?? 0)
|
||||
mainView?.bounds.size.height = size.height - max(statusBarOffset, 0)
|
||||
@@ -310,11 +314,12 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
if statusBarOffset >= CGFloat.ulpOfOne {
|
||||
statusBarFrame.size.height = statusBarOffset
|
||||
}
|
||||
tapView?.transform = .identity
|
||||
tapView?.layer.transform = CATransform3DIdentity
|
||||
tapView?.bounds = mainView!.bounds
|
||||
statusBarView?.frame = statusBarFrame
|
||||
statusBarView?.alpha = 1
|
||||
|
||||
var x: CGFloat = 0
|
||||
switch sideMenuManager.menuPresentMode {
|
||||
|
||||
case .viewSlideOut, .viewSlideInOut:
|
||||
@@ -323,7 +328,7 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
mainView?.layer.shadowOpacity = sideMenuManager.menuShadowOpacity
|
||||
mainView?.layer.shadowOffset = CGSize(width: 0, height: 0)
|
||||
let direction:CGFloat = presentDirection == .left ? 1 : -1
|
||||
mainView?.frame.origin.x = direction * (menuView!.frame.width)
|
||||
x = direction * (menuView!.frame.width)
|
||||
|
||||
case .menuSlideIn, .menuDissolveIn:
|
||||
if sideMenuManager.menuBlurEffectStyle == nil {
|
||||
@@ -332,17 +337,21 @@ open class SideMenuTransition: UIPercentDrivenInteractiveTransition {
|
||||
menuView?.layer.shadowOpacity = sideMenuManager.menuShadowOpacity
|
||||
menuView?.layer.shadowOffset = CGSize(width: 0, height: 0)
|
||||
}
|
||||
mainView?.frame.origin.x = 0
|
||||
}
|
||||
|
||||
if sideMenuManager.menuPresentMode != .viewSlideOut {
|
||||
mainView?.transform = CGAffineTransform(scaleX: sideMenuManager.menuAnimationTransformScaleFactor, y: sideMenuManager.menuAnimationTransformScaleFactor)
|
||||
if sideMenuManager.menuAnimationTransformScaleFactor > 1 {
|
||||
tapView?.transform = mainView!.transform
|
||||
}
|
||||
let f = sideMenuManager.menuPresentMode != .viewSlideOut ? sideMenuManager.menuAnimationTransformScaleFactor : 1
|
||||
if sideMenuManager.menuPresentMode == .viewSlideInOut || sideMenuManager.menuPresentMode == .viewSlideOut {
|
||||
mainView?.alpha = 1 - sideMenuManager.menuAnimationFadeStrength
|
||||
}
|
||||
|
||||
mainView?.layer.transform = CATransform3D(m11: f, m12: 0, m13: 0, m14: 0,
|
||||
m21: 0, m22: f, m23: 0, m24: 0,
|
||||
m31: 0, m32: 0, m33: 1, m34: 0,
|
||||
m41: x, m42: 0, m43: 0, m44: 1)
|
||||
if f > 1 {
|
||||
tapView?.layer.transform = mainView!.layer.transform
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
@@ -447,6 +456,18 @@ extension SideMenuTransition: UIViewControllerAnimatedTransitioning {
|
||||
}
|
||||
|
||||
hideMenuStart()
|
||||
|
||||
if #available(iOS 11.0, *), sideMenuManager.menuAnimationTransformScaleFactor != 1.0 {
|
||||
mainViewController?.additionalSafeAreaInsets.top = topView.safeAreaLayoutGuide.layoutFrame.minY
|
||||
if sideMenuManager.menuAnimationTransformScaleFactor < 1.0 {
|
||||
mainViewController?.additionalSafeAreaInsets.bottom = topView.frame.maxY - topView.safeAreaLayoutGuide.layoutFrame.maxY
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if #available(iOS 11.0, *), sideMenuManager.menuAnimationTransformScaleFactor != 1.0 {
|
||||
mainViewController?.additionalSafeAreaInsets.top = 0
|
||||
mainViewController?.additionalSafeAreaInsets.bottom = 0
|
||||
}
|
||||
}
|
||||
|
||||
let animate = {
|
||||
@@ -465,8 +486,23 @@ extension SideMenuTransition: UIViewControllerAnimatedTransitioning {
|
||||
let viewControllerForPresentedMenu = self.mainViewController
|
||||
|
||||
if self.presenting {
|
||||
if #available(iOS 11.0, *), self.sideMenuManager.menuAnimationTransformScaleFactor != 1.0 {
|
||||
self.mainViewController?.additionalSafeAreaInsets.top = 0
|
||||
self.mainViewController?.additionalSafeAreaInsets.bottom = 0
|
||||
}
|
||||
|
||||
self.hideMenuComplete()
|
||||
} else {
|
||||
if #available(iOS 11.0, *), self.sideMenuManager.menuAnimationTransformScaleFactor != 1.0 {
|
||||
let transform = topView.layer.transform
|
||||
topView.layer.transform = CATransform3DIdentity
|
||||
self.mainViewController?.additionalSafeAreaInsets.top = topView.safeAreaLayoutGuide.layoutFrame.minY
|
||||
if self.sideMenuManager.menuAnimationTransformScaleFactor < 1.0 {
|
||||
self.mainViewController?.additionalSafeAreaInsets.bottom = topView.frame.maxY - topView.safeAreaLayoutGuide.layoutFrame.maxY
|
||||
}
|
||||
topView.layer.transform = transform
|
||||
}
|
||||
|
||||
self.presentMenuComplete()
|
||||
}
|
||||
|
||||
@@ -495,7 +531,7 @@ extension SideMenuTransition: UIViewControllerAnimatedTransitioning {
|
||||
tapView.bounds = container.bounds
|
||||
tapView.center = topView.center
|
||||
if self.sideMenuManager.menuAnimationTransformScaleFactor > 1 {
|
||||
tapView.transform = topView.transform
|
||||
tapView.layer.transform = topView.layer.transform
|
||||
}
|
||||
self.tapView = tapView
|
||||
}
|
||||
|
||||
@@ -1,39 +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] Xcode 9.
|
||||
- [x] Swift 4.
|
||||
- [x] iOS 8 or higher.
|
||||
* Xcode 9.
|
||||
* iOS 8 or higher.
|
||||
|
||||
## Installation
|
||||
### CocoaPods
|
||||
@@ -83,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
|
||||
@@ -138,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
|
||||
|
||||
Reference in New Issue
Block a user