Compare commits

..

19 Commits

Author SHA1 Message Date
jonkykong 10345d4776 Updated spec. 2016-01-08 16:12:41 -08:00
Jon Kent a49883580d Update README.md 2016-01-06 23:57:18 -08:00
Jon Kent a94dd58950 Update README.md 2016-01-06 23:50:55 -08:00
Jon Kent e360068f68 Update README.md 2016-01-06 21:55:49 -08:00
jonkykong a4aac9536a Updated pod spec version. 2016-01-06 21:15:54 -08:00
jonkykong fb20329cb1 Updated project to recommended settings. 2016-01-06 21:14:20 -08:00
jonkykong d62695ae2d Merge branch 'master' of https://github.com/jonkykong/SideMenu
* 'master' of https://github.com/jonkykong/SideMenu:
  Update README.md
  Update README.md
2016-01-06 21:11:21 -08:00
jonkykong 8d78be525e Updated storyboard. 2016-01-06 21:11:08 -08:00
Jon Kent 7e4b8365ee Update README.md 2016-01-06 11:39:09 -08:00
jonkykong 1d32cd1b7b Update README.md 2016-01-05 21:10:23 -08:00
jonkykong f2299bb5e4 Update README.md 2016-01-05 20:10:50 -08:00
jonkykong 5aac1f26e8 One more class name refactor + better screenshots. 2016-01-05 19:44:07 -08:00
jonkykong ef1d05607f Updated pod version. 2016-01-05 15:31:11 -08:00
jonkykong aca41e0ed3 Removed unnecessary line of code. 2016-01-05 15:28:33 -08:00
jonkykong 4b07c5ffe5 Update README.md 2016-01-05 15:10:58 -08:00
jonkykong 8305c2f13d Updated asset. 2016-01-05 15:03:39 -08:00
jonkykong 3631570657 Merge branch 'master' of https://github.com/jonkykong/SideMenu
* 'master' of https://github.com/jonkykong/SideMenu:
  Update README.md
2016-01-05 14:33:17 -08:00
jonkykong 74ccc791f8 Refactored UILeft/RightMenuNavigationController into single UIMenuNavigationController class. 2016-01-05 14:33:06 -08:00
jonkykong 374818587a Update README.md 2015-12-29 22:26:27 -08:00
16 changed files with 275 additions and 264 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
PODS:
- SideMenu (0.1.0)
- SideMenu (0.1.4)
DEPENDENCIES:
- SideMenu (from `../`)
@@ -9,6 +9,6 @@ EXTERNAL SOURCES:
:path: ../
SPEC CHECKSUMS:
SideMenu: 62c97561370244e645f3bccecb8a9055f78d0ccc
SideMenu: 09bc4ab16e392aea64caf052074efd63ef726b6a
COCOAPODS: 0.39.0
+4 -3
View File
@@ -1,16 +1,17 @@
{
"name": "SideMenu",
"version": "0.1.0",
"version": "0.1.4",
"summary": "SideMenu is a simple and versatile side menu control.",
"description": "SideMenu is a simple and versatile side menu control. It's highly customizable, but can also be implemented in storyboard without a single line of code. The are three standard animation styles to choose from along with several other options for further customization if desired.",
"description": "SideMenu is a simple and versatile side menu control. It's highly customizable, but can also be implemented in storyboard without a single line of code. The are three standard animation styles to choose from along with several other options for further customization if desired. Just type SideMenuManager.menu... and code completion will show you everything you can customize.",
"homepage": "https://github.com/jonkykong/SideMenu",
"screenshots": "https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/Preview.gif",
"license": "MIT",
"authors": {
"jonkykong": "jonk@jonked.com"
},
"source": {
"git": "https://github.com/jonkykong/SideMenu.git",
"tag": "0.1.0"
"tag": "0.1.4"
},
"platforms": {
"ios": "8.0"
+2 -2
View File
@@ -1,5 +1,5 @@
PODS:
- SideMenu (0.1.0)
- SideMenu (0.1.4)
DEPENDENCIES:
- SideMenu (from `../`)
@@ -9,6 +9,6 @@ EXTERNAL SOURCES:
:path: ../
SPEC CHECKSUMS:
SideMenu: 62c97561370244e645f3bccecb8a9055f78d0ccc
SideMenu: 09bc4ab16e392aea64caf052074efd63ef726b6a
COCOAPODS: 0.39.0
+8 -1
View File
@@ -355,7 +355,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0720;
};
buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */;
compatibilityVersion = "Xcode 3.2";
@@ -485,6 +485,7 @@
OTHER_LDFLAGS = "";
OTHER_LIBTOOLFLAGS = "";
PODS_ROOT = "$(SRCROOT)";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Pods_SideMenu_Example;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -516,6 +517,7 @@
OTHER_LDFLAGS = "";
OTHER_LIBTOOLFLAGS = "";
PODS_ROOT = "$(SRCROOT)";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Pods_SideMenu_Tests;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -546,6 +548,7 @@
OTHER_LDFLAGS = "";
OTHER_LIBTOOLFLAGS = "";
PODS_ROOT = "$(SRCROOT)";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Pods_SideMenu_Example;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -573,6 +576,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
@@ -624,6 +628,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = "Target Support Files/SideMenu/SideMenu.modulemap";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = SideMenu;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -654,6 +659,7 @@
OTHER_LDFLAGS = "";
OTHER_LIBTOOLFLAGS = "";
PODS_ROOT = "$(SRCROOT)";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = Pods_SideMenu_Tests;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -682,6 +688,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MODULEMAP_FILE = "Target Support Files/SideMenu/SideMenu.modulemap";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = SideMenu;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
@@ -1,36 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForAnalyzing = "YES"
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES">
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = 'primary'
BlueprintIdentifier = '6D5700AB4DD41D539909DBA7'
BlueprintName = 'SideMenu'
ReferencedContainer = 'container:Pods.xcodeproj'
BuildableName = 'SideMenu.framework'>
BuildableIdentifier = "primary"
BlueprintIdentifier = "92B1C7A9E8122442B031A44C1CA691AF"
BuildableName = "SideMenu.framework"
BlueprintName = "SideMenu"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
@@ -38,17 +41,25 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
buildConfiguration = "Debug"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92B1C7A9E8122442B031A44C1CA691AF"
BuildableName = "SideMenu.framework"
BlueprintName = "SideMenu"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES">
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
@@ -2,25 +2,25 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
@@ -2,25 +2,25 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
+20 -20
View File
@@ -2,25 +2,25 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
+9 -5
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="yAA-s6-Bam">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
@@ -92,7 +93,7 @@
<action selector="changeSegment:" destination="QHN-nZ-kbB" eventType="valueChanged" id="5cv-dF-wWs"/>
</connections>
</segmentedControl>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.01" minValue="0.001" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="Xp9-C5-Td1">
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.001" minValue="0.001" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="Xp9-C5-Td1">
<rect key="frame" x="18" y="368" width="284" height="31"/>
<color key="thumbTintColor" red="0.25098040700000002" green="0.0" blue="0.50196081400000003" alpha="1" colorSpace="calibratedRGB"/>
<connections>
@@ -242,15 +243,18 @@
</objects>
<point key="canvasLocation" x="142" y="336"/>
</scene>
<!--Left Menu Navigation Controller-->
<!--Side Menu Navigation Controller-->
<scene sceneID="Zbc-0f-8nT">
<objects>
<navigationController storyboardIdentifier="UILeftMenuNavigationController" navigationBarHidden="YES" id="DuX-EW-0mP" customClass="UILeftMenuNavigationController" customModule="SideMenu" sceneMemberID="viewController">
<navigationController storyboardIdentifier="LeftMenuNavigationController" navigationBarHidden="YES" id="DuX-EW-0mP" customClass="UISideMenuNavigationController" customModule="SideMenu" sceneMemberID="viewController">
<navigationItem key="navigationItem" id="ipz-Lx-Wgf"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="35F-wh-r6h">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="leftSide" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<segue destination="V6g-oO-Tbm" kind="relationship" relationship="rootViewController" id="Zvt-Bp-XoT"/>
</connections>
@@ -375,10 +379,10 @@
</objects>
<point key="canvasLocation" x="3896.25" y="0.0"/>
</scene>
<!--Right Menu Navigation Controller-->
<!--Side Menu Navigation Controller-->
<scene sceneID="kei-0w-mFw">
<objects>
<navigationController storyboardIdentifier="UIRightMenuNavigationController" navigationBarHidden="YES" id="z7k-fk-pfc" customClass="UIRightMenuNavigationController" customModule="SideMenu" sceneMemberID="viewController">
<navigationController storyboardIdentifier="RightMenuNavigationController" navigationBarHidden="YES" id="z7k-fk-pfc" customClass="UISideMenuNavigationController" customModule="SideMenu" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="qOd-yQ-2i8">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
+2 -3
View File
@@ -26,8 +26,8 @@ class MainViewController: UIViewController {
private func setupSideMenu() {
// Define the menus
SideMenuManager.menuLeftNavigationController = storyboard!.instantiateViewControllerWithIdentifier("UILeftMenuNavigationController") as? UILeftMenuNavigationController
SideMenuManager.menuRightNavigationController = storyboard!.instantiateViewControllerWithIdentifier("UIRightMenuNavigationController") as? UIRightMenuNavigationController
SideMenuManager.menuLeftNavigationController = storyboard!.instantiateViewControllerWithIdentifier("LeftMenuNavigationController") as? UISideMenuNavigationController
SideMenuManager.menuRightNavigationController = storyboard!.instantiateViewControllerWithIdentifier("RightMenuNavigationController") as? UISideMenuNavigationController
// Enable gestures. The left and/or right menus must be set up above for these to work.
// Note that these continue to work on the Navigation Controller independent of the View Controller it displays!
@@ -57,7 +57,6 @@ class MainViewController: UIViewController {
}
@IBAction private func changeSegment(segmentControl: UISegmentedControl) {
presentViewController(SideMenuManager.menuLeftNavigationController!, animated: true, completion: nil)
switch segmentControl {
case presentModeSegmentedControl:
let modes:[SideMenuManager.MenuPresentMode] = [.MenuSlideIn, .ViewSlideOut, .MenuDissolveIn]
+133 -157
View File
@@ -12,168 +12,143 @@
SideMenuManager.menuAddScreenEdgePanGesturesToPresent(toView: self.navigationController!.view)
*/
private func menuViewDidAppear(navigationController: UINavigationController) {
// we had presented a view before, so lets dismiss ourselves as already acted upon
if navigationController.view.hidden {
SideMenuManager.hideMenuComplete()
navigationController.dismissViewControllerAnimated(false, completion: { () -> Void in
navigationController.view.hidden = false
})
}
}
private func menuViewWillDisappear(navigationController: UINavigationController) {
// 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 !navigationController.isBeingDismissed() {
if let mainView = navigationController.presentingViewController?.view {
switch SideMenuManager.menuPresentMode {
case .ViewSlideOut:
mainView.superview?.insertSubview(navigationController.view, belowSubview: mainView)
case .MenuSlideIn, .MenuDissolveIn:
mainView.superview?.insertSubview(navigationController.view, aboveSubview: SideMenuManager.tapView)
public class UISideMenuNavigationController: UINavigationController {
@IBInspectable public var leftSide:Bool = false {
didSet {
if isViewLoaded() { // suppress warnings
didSetSide()
}
}
}
}
private func menuViewDidDisappear(navigationController: UINavigationController) {
// we're presenting a view controller from the menu, so we need to hide the menu so it isn't g when the presented view is dismissed.
if !navigationController.isBeingDismissed() {
navigationController.view.hidden = true
SideMenuManager.hideMenuAppearance()
override public func viewDidLoad() {
super.viewDidLoad()
didSetSide()
}
}
private func menuViewWillTransitionToSize(navigationController: UINavigationController, size: CGSize, coordinator: UIViewControllerTransitionCoordinator) {
// don't bother resizing if the view isn't visible
if navigationController.view.hidden {
return
private func didSetSide() {
if leftSide {
SideMenuManager.menuLeftNavigationController = self
} else {
SideMenuManager.menuRightNavigationController = self
}
}
SideMenuManager.statusBarView?.hidden = true
coordinator.animateAlongsideTransition({ (context) -> Void in
SideMenuManager.presentMenuAppearance(forSize: size)
}) { (context) -> Void in
SideMenuManager.statusBarView?.hidden = false
override public func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
// we had presented a view before, so lets dismiss ourselves as already acted upon
if view.hidden {
SideMenuManager.hideMenuComplete()
dismissViewControllerAnimated(false, completion: { () -> Void in
self.view.hidden = false
})
}
}
}
private func menuPushViewController(navigationController: UINavigationController, viewController: UIViewController, animated: Bool) {
if let menuViewController: UINavigationController = SideMenuManager.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
navigationController.dismissViewControllerAnimated(true, completion: nil)
navigationController.visibleViewController?.viewWillAppear(false) // Hack: force selection to get cleared on UITableViewControllers when reappearing using custom transitions
})
UIView.animateWithDuration(SideMenuManager.menuAnimationDismissDuration, animations: { () -> Void in
SideMenuManager.hideMenuAppearance()
})
if SideMenuManager.menuAllowPopIfPossible {
for subViewController in presentingViewController.viewControllers {
if subViewController.dynamicType == viewController.dynamicType {
presentingViewController.popToViewController(subViewController, animated: animated)
override public 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:
mainView.superview?.insertSubview(view, belowSubview: mainView)
case .MenuSlideIn, .MenuDissolveIn:
mainView.superview?.insertSubview(view, aboveSubview: SideMenuManager.tapView)
}
}
}
}
override public func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
// we're presenting a view controller from the menu, so we need to hide the menu so it isn't g when the presented view is dismissed.
if !isBeingDismissed() {
view.hidden = true
SideMenuManager.hideMenuStart()
}
}
override public func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
// don't bother resizing if the view isn't visible
if view.hidden {
return
}
SideMenuManager.statusBarView?.hidden = true
coordinator.animateAlongsideTransition({ (context) -> Void in
SideMenuManager.presentMenuStart(forSize: size)
}) { (context) -> Void in
SideMenuManager.statusBarView?.hidden = false
}
}
override public func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let menuViewController: UINavigationController = SideMenuManager.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController : SideMenuManager.menuRightNavigationController,
presentingViewController = menuViewController.presentingViewController as? UINavigationController {
presentingViewController.prepareForSegue(segue, sender: sender)
}
}
override public func shouldPerformSegueWithIdentifier(identifier: String, sender: AnyObject?) -> Bool {
if let menuViewController: UINavigationController = SideMenuManager.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController : SideMenuManager.menuRightNavigationController,
presentingViewController = menuViewController.presentingViewController as? UINavigationController {
return presentingViewController.shouldPerformSegueWithIdentifier(identifier, sender: sender)
}
return super.shouldPerformSegueWithIdentifier(identifier, sender: sender)
}
override public func pushViewController(viewController: UIViewController, animated: Bool) {
if let menuViewController: UINavigationController = SideMenuManager.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
SideMenuManager.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("Warning: attempted to push a ViewController from a ViewController that doesn't have 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()
} else {
menuViewController.presentViewController(viewController, animated: animated, completion: nil)
print("Warning: attempted to push a ViewController from a ViewController that doesn't have a NavigationController. It will be presented it instead.")
}
}
}
public class UILeftMenuNavigationController: UINavigationController {
override public func viewDidLoad() {
super.viewDidLoad()
SideMenuManager.menuLeftNavigationController = self
}
override public func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
menuViewDidAppear(self)
}
override public func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
menuViewWillDisappear(self)
}
override public func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
menuViewDidDisappear(self)
}
override public func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
menuViewWillTransitionToSize(self, size: size, coordinator: coordinator)
}
override public func pushViewController(viewController: UIViewController, animated: Bool) {
menuPushViewController(self, viewController: viewController, animated: animated)
}
}
public class UIRightMenuNavigationController: UINavigationController {
override public func viewDidLoad() {
super.viewDidLoad()
SideMenuManager.menuRightNavigationController = self
}
override public func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
menuViewDidAppear(self)
}
override public func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
menuViewWillDisappear(self)
}
override public func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
menuViewDidDisappear(self)
}
override public func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
menuViewWillTransitionToSize(self, size: size, coordinator: coordinator)
}
override public func pushViewController(viewController: UIViewController, animated: Bool) {
menuPushViewController(self, viewController: viewController, animated: animated)
}
}
public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewControllerAnimatedTransitioning, UIViewControllerTransitioningDelegate {
public enum MenuPresentMode {
@@ -218,7 +193,7 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
// prevent instantiation
private override init() {}
public static var menuLeftNavigationController: UILeftMenuNavigationController? {
public static var menuLeftNavigationController: UISideMenuNavigationController? {
willSet {
if menuLeftNavigationController != nil {
let originalBlurEffectStyle = menuBlurEffectStyle
@@ -239,7 +214,7 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
}
}
public static var menuRightNavigationController: UIRightMenuNavigationController? {
public static var menuRightNavigationController: UISideMenuNavigationController? {
willSet {
if menuRightNavigationController != nil {
let originalBlurEffectStyle = menuBlurEffectStyle
@@ -464,7 +439,7 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
return viewController
}
private class func hideMenuAppearance() {
private class func hideMenuStart() {
let mainViewController = viewControllerForPresentedMenu!
let menuView = presentDirection == .Left ? menuLeftNavigationController!.view : menuRightNavigationController!.view
menuView.transform = CGAffineTransformIdentity
@@ -510,7 +485,7 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
}
}
private class func presentMenuAppearance(forSize size: CGSize = UIScreen.mainScreen().bounds.size) {
private class func presentMenuStart(forSize size: CGSize = UIScreen.mainScreen().bounds.size) {
let mainViewController = viewControllerForPresentedMenu!
if let menuView = presentDirection == .Left ? menuLeftNavigationController?.view : menuRightNavigationController?.view {
menuView.transform = CGAffineTransformIdentity
@@ -574,6 +549,8 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
// animate a change from one viewcontroller to another
public func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
let statusBarStyle = SideMenuManager.visibleViewController()?.preferredStatusBarStyle()
// get reference to our fromView, toView and the container view that we should perform the transition in
let container = transitionContext.containerView()!
if let menuBackgroundColor = SideMenuManager.menuAnimationBackgroundColor {
@@ -627,7 +604,7 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
}
SideMenuManager.tapView = tapView
SideMenuManager.hideMenuAppearance() // offstage for interactive
SideMenuManager.hideMenuStart() // offstage for interactive
NSNotificationCenter.defaultCenter().addObserver(SideMenuManager.singleton, selector:"applicationDidEnterBackgroundNotification", name: UIApplicationDidEnterBackgroundNotification, object: nil)
}
@@ -637,16 +614,15 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
let options: UIViewAnimationOptions = SideMenuManager.interactive ? .CurveLinear : .CurveEaseInOut
UIView.animateWithDuration(duration, delay: 0, options: options, animations: { () -> Void in
if SideMenuManager.presenting {
SideMenuManager.presentMenuAppearance() // onstage items: slide in
SideMenuManager.presentMenuStart() // onstage items: slide in
}
else {
SideMenuManager.hideMenuAppearance()
SideMenuManager.hideMenuStart()
}
}) { (finished) -> Void in
// if UIApplication.sharedApplication().visibleViewController!.preferredStatusBarStyle() != statusBarStyle {
// // See http://www.openradar.me/21961293
// print("Warning: do not change the status bar style while using interactive transitions or you risk transitions not properly completing.")
// }
if SideMenuManager.visibleViewController()?.preferredStatusBarStyle() != statusBarStyle {
print("Warning: do not change the status bar style while using custom transitions or you risk transitions not properly completing and locking up the UI. See http://www.openradar.me/21961293")
}
// tell our transitionContext object that we've finished animating
if transitionContext.transitionWasCancelled() {
if SideMenuManager.presenting {
@@ -708,7 +684,7 @@ public class SideMenuManager: UIPercentDrivenInteractiveTransition, UIViewContro
func applicationDidEnterBackgroundNotification() {
if let menuViewController: UINavigationController = SideMenuManager.presentDirection == .Left ? SideMenuManager.menuLeftNavigationController : SideMenuManager.menuRightNavigationController {
SideMenuManager.hideMenuAppearance()
SideMenuManager.hideMenuStart()
SideMenuManager.hideMenuComplete()
menuViewController.dismissViewControllerAnimated(false, completion: nil)
}
+27 -14
View File
@@ -3,7 +3,17 @@
[![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)
SideMenu is a simple and versatile side menu control written in Swift. The are three standard animation styles to choose from along with several other options for further customization if desired.
SideMenu is a simple and versatile side menu control written in Swift.
* There are three standard animation styles to choose from.
* It's highly customizable without needing to write tons of custom code.
* It supports continuous swiping between each side menu in a single gesture.
* Since it uses custom transitions it can be presented and dismissed the same as any other View Controller. This means **it can be implemented in storyboard without a single line of code**.
Check out the example project to see it in action.
PS: It makes me happy when you ★ this repo.
[Demo via Appetizer](https://appetize.io/app/682u2wn33p1mgpzrtwyrxxz1w4)
![](etc/Preview.gif)
@@ -22,24 +32,27 @@ pod "SideMenu"
```
## Usage
SideMenu is highly customizable, but can also be implemented in storyboard without a single line of code. Check out the example project to see it in action.
### 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**. 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)
### Storyboard
1. Create a Navigation Controller. Set the custom class of the Navigation Controller to be `UILeftMenuNavigationController` or `UIRightMenuNavigationController` (whichever you prefer) in the **Identity Inspector**.
2. Create a root View Controller for the Navigation Controller in step 1. Set up any Triggered Segues you want in that View Controller.
3. From any View Controller, add a UIButton or UIBarButton. Set that button's Triggered Segues action to modally present the Navigation Controller from step 1.
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)
*Note: you can only enable gestures with code.*
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)
### Code
That's it. *Note: you can only enable gestures in code.*
### Code Implementation
In your View Controller's `viewDidLoad` event, do something like this:
``` swift
// Define the menus
let leftMenuNavigationController = UILeftMenuNavigationController()
// UILeftMenuNavigationController is a subclass of UINavigationController, so do any additional configuration of it here
let leftMenuNavigationController = UIMenuNavigationController()
leftMenuNavigationController.leftSide = true
// UIMenuNavigationController is a subclass of UINavigationController, so do any additional configuration of it here like setting it's viewControllers.
SideMenuManager.menuLeftNavigationController = leftMenuNavigationController
let rightMenuNavigationController = UIRightMenuNavigationController()
// UIRightMenuNavigationController is a subclass of UINavigationController, so do any additional configuration of it here
let rightMenuNavigationController = UIMenuNavigationController()
// UIMenuNavigationController is a subclass of UINavigationController, so do any additional configuration of it here like setting it's viewControllers.
SideMenuManager.menuRightNavigationController = rightMenuNavigationController
// Enable gestures. The left and/or right menus must be set up above for these to work.
@@ -51,7 +64,7 @@ Then from a button, do something like this:
``` swift
presentViewController(SideMenuManager.menuLeftNavigationController!, animated: true, completion: nil)
```
That's it.
### Customization
Just type `SideMenuManager.menu...` and code completion will show you everything you can customize (defaults are shown below for reference):
``` swift
@@ -79,7 +92,7 @@ menuAddPanGestureToPresent(toView toView: UIView) -> UIPanGestureRecognizer
```
## Known Issues
Don't try to change the status bar appearance when presenting a menu. When used with quick gestures/animations, it causes the presentation animation to not complete properly and locks up the UI. See [radar 21961293](http://www.openradar.me/21961293) for more information.
Don't try to change the status bar appearance when presenting a menu. When used with quick gestures/animations, it causes the presentation animation to not complete properly and locks the UI. See [radar 21961293](http://www.openradar.me/21961293) for more information.
## License
+3 -3
View File
@@ -8,8 +8,8 @@
Pod::Spec.new do |s|
s.name = "SideMenu"
s.version = "0.1.0"
s.summary = "SideMenu is a simple and versatile side menu control."
s.version = "0.1.5"
s.summary = "Simple side menu control in Swift inspired by Facebook. Right and Left sides. No coding required."
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
DESC
s.homepage = "https://github.com/jonkykong/SideMenu"
# s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
s.screenshot = "https://raw.githubusercontent.com/jonkykong/SideMenu/master/etc/Preview.gif"
s.license = 'MIT'
s.author = { "jonkykong" => "jonk@jonked.com" }
s.source = { :git => "https://github.com/jonkykong/SideMenu.git", :tag => s.version.to_s }
Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB