Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4aa5ef2dcb | |||
| 347f476296 | |||
| 4828c02cc8 | |||
| 3863fffb7e | |||
| a54bb35fde | |||
| 129fd45f5e | |||
| cb6b297068 | |||
| 49b5f0c4ab | |||
| 7e1b32733a | |||
| b7a769db31 | |||
| a6464d3efa |
@@ -153,9 +153,9 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC
|
||||
|
||||
internal class func hideMenuStart() {
|
||||
NSNotificationCenter.defaultCenter().removeObserver(SideMenuTransition.singleton)
|
||||
|
||||
let mainViewController = SideMenuTransition.viewControllerForPresentedMenu!
|
||||
let menuView = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController!.view : SideMenuManager.menuRightNavigationController!.view
|
||||
guard let mainViewController = SideMenuTransition.viewControllerForPresentedMenu,
|
||||
let menuView = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController?.view : SideMenuManager.menuRightNavigationController?.view else {return}
|
||||
|
||||
menuView.transform = CGAffineTransformIdentity
|
||||
mainViewController.view.transform = CGAffineTransformIdentity
|
||||
mainViewController.view.alpha = 1
|
||||
@@ -191,8 +191,11 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC
|
||||
}
|
||||
|
||||
internal class func hideMenuComplete() {
|
||||
let mainViewController = SideMenuTransition.viewControllerForPresentedMenu!
|
||||
let menuView = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController!.view : SideMenuManager.menuRightNavigationController!.view
|
||||
guard let mainViewController = SideMenuTransition.viewControllerForPresentedMenu,
|
||||
let menuView = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController?.view : SideMenuManager.menuRightNavigationController?.view else {
|
||||
return
|
||||
}
|
||||
|
||||
SideMenuTransition.tapView.removeFromSuperview()
|
||||
SideMenuTransition.statusBarView?.removeFromSuperview()
|
||||
mainViewController.view.motionEffects.removeAll()
|
||||
@@ -205,11 +208,11 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC
|
||||
}
|
||||
|
||||
internal class func presentMenuStart(forSize size: CGSize = SideMenuManager.appScreenRect.size) {
|
||||
guard let menuView = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController?.view : SideMenuManager.menuRightNavigationController?.view else {
|
||||
return
|
||||
guard let menuView = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController?.view : SideMenuManager.menuRightNavigationController?.view,
|
||||
let mainViewController = SideMenuTransition.viewControllerForPresentedMenu else {
|
||||
return
|
||||
}
|
||||
|
||||
let mainViewController = SideMenuTransition.viewControllerForPresentedMenu!
|
||||
menuView.transform = CGAffineTransformIdentity
|
||||
mainViewController.view.transform = CGAffineTransformIdentity
|
||||
menuView.frame.size.width = SideMenuManager.menuWidth
|
||||
@@ -254,8 +257,10 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC
|
||||
|
||||
internal class func presentMenuComplete() {
|
||||
NSNotificationCenter.defaultCenter().addObserver(SideMenuTransition.singleton, selector:#selector(SideMenuTransition.applicationDidEnterBackgroundNotification), name: UIApplicationDidEnterBackgroundNotification, object: nil)
|
||||
|
||||
let mainViewController = SideMenuTransition.viewControllerForPresentedMenu!
|
||||
guard let mainViewController = SideMenuTransition.viewControllerForPresentedMenu else {
|
||||
return
|
||||
}
|
||||
|
||||
switch SideMenuManager.menuPresentMode {
|
||||
case .MenuSlideIn, .MenuDissolveIn, .ViewSlideInOut:
|
||||
if SideMenuManager.menuParallaxStrength != 0 {
|
||||
@@ -347,10 +352,10 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC
|
||||
UIView.animateWithDuration(duration, delay: 0, options: options, animations: { () -> Void in
|
||||
if self.presenting {
|
||||
SideMenuTransition.presentMenuStart() // onstage items: slide in
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SideMenuTransition.hideMenuStart()
|
||||
}
|
||||
menuView.userInteractionEnabled = false
|
||||
}) { (finished) -> Void in
|
||||
// tell our transitionContext object that we've finished animating
|
||||
if transitionContext.transitionWasCancelled() {
|
||||
@@ -361,6 +366,8 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC
|
||||
} else {
|
||||
SideMenuTransition.presentMenuComplete()
|
||||
}
|
||||
menuView.userInteractionEnabled = true
|
||||
|
||||
transitionContext.completeTransition(false)
|
||||
|
||||
if SideMenuTransition.switchMenus {
|
||||
@@ -373,6 +380,7 @@ internal class SideMenuTransition: UIPercentDrivenInteractiveTransition, UIViewC
|
||||
|
||||
if self.presenting {
|
||||
SideMenuTransition.presentMenuComplete()
|
||||
menuView.userInteractionEnabled = true
|
||||
transitionContext.completeTransition(true)
|
||||
switch SideMenuManager.menuPresentMode {
|
||||
case .ViewSlideOut:
|
||||
|
||||
@@ -115,44 +115,49 @@ public class UISideMenuNavigationController: UINavigationController {
|
||||
}
|
||||
|
||||
override public func pushViewController(viewController: UIViewController, animated: Bool) {
|
||||
if let menuViewController: UINavigationController = SideMenuTransition.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController : SideMenuManager.menuRightNavigationController {
|
||||
if let presentingViewController = menuViewController.presentingViewController as? UINavigationController {
|
||||
|
||||
// to avoid overlapping dismiss & pop/push calls, create a transaction block where the menu
|
||||
// is dismissed after showing the appropriate screen
|
||||
CATransaction.begin()
|
||||
CATransaction.setCompletionBlock( { () -> Void in
|
||||
self.dismissViewControllerAnimated(true, completion: nil)
|
||||
self.visibleViewController?.viewWillAppear(false) // Hack: force selection to get cleared on UITableViewControllers when reappearing using custom transitions
|
||||
})
|
||||
|
||||
UIView.animateWithDuration(SideMenuManager.menuAnimationDismissDuration, animations: { () -> Void in
|
||||
SideMenuTransition.hideMenuStart()
|
||||
})
|
||||
|
||||
if SideMenuManager.menuAllowPopIfPossible {
|
||||
for subViewController in presentingViewController.viewControllers {
|
||||
if subViewController.dynamicType == viewController.dynamicType {
|
||||
presentingViewController.popToViewController(subViewController, animated: animated)
|
||||
CATransaction.commit()
|
||||
return
|
||||
}
|
||||
}
|
||||
guard viewControllers.count > 0 else {
|
||||
// NOTE: pushViewController is called by init(rootViewController: UIViewController)
|
||||
// so we must perform the normal super method in this case.
|
||||
super.pushViewController(viewController, animated: true)
|
||||
return
|
||||
}
|
||||
|
||||
guard let presentingViewController = presentingViewController as? UINavigationController else {
|
||||
presentViewController(viewController, animated: animated, completion: nil)
|
||||
print("SideMenu Warning: cannot push a ViewController from a ViewController without a NavigationController. It will be presented it instead.")
|
||||
return
|
||||
}
|
||||
|
||||
// to avoid overlapping dismiss & pop/push calls, create a transaction block where the menu
|
||||
// is dismissed after showing the appropriate screen
|
||||
CATransaction.begin()
|
||||
CATransaction.setCompletionBlock( { () -> Void in
|
||||
self.dismissViewControllerAnimated(true, completion: nil)
|
||||
self.visibleViewController?.viewWillAppear(false) // Hack: force selection to get cleared on UITableViewControllers when reappearing using custom transitions
|
||||
})
|
||||
|
||||
UIView.animateWithDuration(SideMenuManager.menuAnimationDismissDuration, animations: { () -> Void in
|
||||
SideMenuTransition.hideMenuStart()
|
||||
})
|
||||
|
||||
if SideMenuManager.menuAllowPopIfPossible {
|
||||
for subViewController in presentingViewController.viewControllers {
|
||||
if subViewController.dynamicType == viewController.dynamicType {
|
||||
presentingViewController.popToViewController(subViewController, animated: animated)
|
||||
CATransaction.commit()
|
||||
return
|
||||
}
|
||||
if !SideMenuManager.menuAllowPushOfSameClassTwice {
|
||||
if presentingViewController.viewControllers.last?.dynamicType == viewController.dynamicType {
|
||||
CATransaction.commit()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
presentingViewController.pushViewController(viewController, animated: animated)
|
||||
CATransaction.commit()
|
||||
} else {
|
||||
menuViewController.presentViewController(viewController, animated: animated, completion: nil)
|
||||
print("SideMenu Warning: cannot push a ViewController from a ViewController without a NavigationController. It will be presented it instead.")
|
||||
}
|
||||
}
|
||||
if !SideMenuManager.menuAllowPushOfSameClassTwice {
|
||||
if presentingViewController.viewControllers.last?.dynamicType == viewController.dynamicType {
|
||||
CATransaction.commit()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
presentingViewController.pushViewController(viewController, animated: animated)
|
||||
CATransaction.commit()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
[](http://cocoapods.org/pods/SideMenu)
|
||||
|
||||
## Shameless Requests First
|
||||
**1. If you like SideMenu, give it a ★ at the top right of its [GitHub](https://github.com/jonkykong/SideMenu) page.**
|
||||
**1. If you like SideMenu, give it a ★ at the top right of this page.**
|
||||
|
||||
**2. I need an invite to Dribbble to share SideMenu. Invite me: https://dribbble.com/jonkykong**
|
||||
|
||||
## Overview
|
||||
|
||||
SideMenu is a simple and versatile side menu control written in Swift.
|
||||
* **It can be implemented in storyboard without a single line of [code](#code-less-storyboard-implementation).**
|
||||
* Four standard animation styles to choose from (even parallax 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.
|
||||
- [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 (even parallax 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.
|
||||
|
||||
Check out the example project or this [interactive demo](https://appetize.io/app/64a9v3e6b8c6f53zvn5pnny80m) to see it in action!
|
||||
|
||||
@@ -26,7 +26,7 @@ Check out the example project or this [interactive demo](https://appetize.io/app
|
||||

|
||||
|
||||
## Requirements
|
||||
* iOS 8 or higher
|
||||
- [x] iOS 8 or higher
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SideMenu"
|
||||
s.version = "1.1.7"
|
||||
s.version = "1.1.9"
|
||||
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