Compare commits

..

23 Commits

Author SHA1 Message Date
jonkykong 1b6b8c446c Fix for exit gesture cancelling menu taps. 2018-02-20 02:38:33 -08:00
Jon Kent 175042e238 Update README.md 2018-01-26 11:06:54 -08:00
Jon Kent 2a4d78b7fa Update README.md 2018-01-26 11:05:26 -08:00
Jon Kent 8573045525 Update README.md 2018-01-09 02:23:18 -08:00
Jon Kent 9e5b11c1cc Update README.md 2017-12-20 10:00:40 -08:00
Jon Kent ecdbfbb11a Update README.md 2017-12-05 15:44:21 -08:00
Jon Kent 5dc207396f Update README.md 2017-11-21 14:29:57 -08:00
Jon Kent 67886c73a8 Update README.md 2017-11-21 14:29:18 -08:00
jonkykong cbc1ac6624 Update README for Github. 2017-11-21 13:20:38 -08:00
jonkykong 9c7111e7e3 Merge tag '3.1.5'
* tag '3.1.5':
  Updated README requirements.
  Updated README for Cocoapods.
  Exposed defaultManager for Objective-C support.
  Updated podspec.
  Additional changes for objective-C support in UISideMenuNavigationController
  fix objc inference in swift 4
2017-11-21 13:19:21 -08:00
jonkykong df48679df4 Updated README requirements. 2017-11-21 13:15:29 -08:00
jonkykong f32cf72443 Updated README for Cocoapods. 2017-11-21 13:10:30 -08:00
jonkykong b15180fb8a Exposed defaultManager for Objective-C support. 2017-11-21 13:06:57 -08:00
jonkykong 6eae7987ef Updated podspec. 2017-11-21 13:05:03 -08:00
jonkykong c6b7780daf Additional changes for objective-C support in UISideMenuNavigationController 2017-11-21 13:04:52 -08:00
herrernst c54f364d49 fix objc inference in swift 4
in swift 4, swift subclasses of objective-c classes don't export members by default, see https://help.apple.com/xcode/mac/current/#/deve838b19a1
2017-11-07 12:27:45 +01:00
jonkykong 5ac61bc981 Revert README for Cocoapods. 2017-10-31 00:31:17 -07:00
jonkykong b647880794 Merge tag '3.1.4'
* tag '3.1.4':
  Update README for Cocoapods.
  Updated podspec.
  Fixed SideMenu.UISideMenuNavigationController crash on init(nibName:bundle:)
2017-10-31 00:30:51 -07:00
jonkykong 2e684440fc Update README for Cocoapods. 2017-10-31 00:28:19 -07:00
jonkykong 6064d6d5fc Updated podspec. 2017-10-31 00:27:58 -07:00
Lawrence Gimenez d13ed0ea9b Fixed SideMenu.UISideMenuNavigationController crash on init(nibName:bundle:) 2017-10-31 15:06:59 +08:00
jonkykong ef607b3ab2 Update README for Github. 2017-10-28 12:05:27 -07:00
jonkykong 069b974145 Merge tag '3.1.3'
* tag '3.1.3':
  Update README for cocoapods.
  Updated podspec.
  Updated README.
2017-10-28 12:04:53 -07:00
4 changed files with 73 additions and 44 deletions
+10
View File
@@ -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
@objc 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?
@@ -58,7 +51,7 @@ open class UISideMenuNavigationController: UINavigationController {
}
/// Delegate for receiving appear and disappear related events. If `nil` the visible view controller that displays a `UISideMenuNavigationController` automatically receives these events.
weak var sideMenuDelegate: UISideMenuNavigationControllerDelegate?
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 {
@@ -109,6 +102,10 @@ open class UISideMenuNavigationController: UINavigationController {
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)
@@ -140,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) {
@@ -156,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 {
@@ -196,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) {
@@ -219,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,
@@ -276,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()
}
@@ -292,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)
+43 -21
View File
@@ -1,37 +1,59 @@
# ▤ SideMenu
[![Version](https://img.shields.io/cocoapods/v/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![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)
[![Version](https://img.shields.io/cocoapods/v/SideMenu.svg?style=flat-square)](http://cocoapods.org/pods/SideMenu)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat-square)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/SideMenu.svg?style=flat-square)](http://cocoapods.org/pods/SideMenu)
[![Platform](https://img.shields.io/cocoapods/p/SideMenu.svg?style=flat-square)](http://cocoapods.org/pods/SideMenu)
[![Total Downloads](https://img.shields.io/cocoapods/dt/SideMenu.svg?style=social)](http://cocoapods.org/pods/SideMenu)
[![Monthly Downloads](https://img.shields.io/cocoapods/dm/SideMenu.svg?style=social)](http://cocoapods.org/pods/SideMenu)
[![Weekly Downloads](https://img.shields.io/cocoapods/dw/SideMenu.svg?style=social)](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&currency_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&currency_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 |
| --- | --- | --- | --- |
| ![](etc/SlideOut.gif) | ![](etc/SlideIn.gif) | ![](etc/Dissolve.gif) | ![](etc/InOut.gif) |
| ![](https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/SlideOut.gif) | ![](https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/SlideIn.gif) | ![](https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/Dissolve.gif) | ![](https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/InOut.gif) |
## 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.
![](etc/Screenshot1.png)
![](https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/Screenshot1.png)
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.
![](etc/Screenshot2.png)
![](https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/Screenshot2.png)
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.
![](etc/Screenshot3.png)
![](https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/Screenshot3.png)
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
+1 -1
View File
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = "SideMenu"
s.version = "3.1.3"
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.