From 528a5b925c31cd06ec6572eede60eb1052d6ff69 Mon Sep 17 00:00:00 2001 From: jignesh Date: Thu, 28 Jun 2018 12:16:42 +0530 Subject: [PATCH 1/2] Swift 4 migration --- Example/Example.xcodeproj/project.pbxproj | 4 ++-- SideMenuController.xcodeproj/project.pbxproj | 10 ++++++---- Source/SideMenuController+SideOver.swift | 10 +++++----- Source/SideMenuController+SideUnder.swift | 10 +++++----- Source/SideMenuController.swift | 6 +++--- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index d3a6709..4500d39 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -406,7 +406,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.sidemenucontroller.example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -421,7 +421,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.sidemenucontroller.example; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/SideMenuController.xcodeproj/project.pbxproj b/SideMenuController.xcodeproj/project.pbxproj index b4f1c50..596add1 100644 --- a/SideMenuController.xcodeproj/project.pbxproj +++ b/SideMenuController.xcodeproj/project.pbxproj @@ -319,6 +319,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -363,6 +364,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -387,7 +389,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -407,7 +409,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.SideMenuController; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -418,7 +420,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.SideMenuControllerTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -429,7 +431,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.teodorpatras.SideMenuControllerTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Source/SideMenuController+SideOver.swift b/Source/SideMenuController+SideOver.swift index 70cd2ec..de8aa0c 100644 --- a/Source/SideMenuController+SideOver.swift +++ b/Source/SideMenuController+SideOver.swift @@ -52,7 +52,7 @@ extension SideMenuController { } } - func handleSidePanelPan(_ recognizer: UIPanGestureRecognizer){ + @objc func handleSidePanelPan(_ recognizer: UIPanGestureRecognizer){ guard canDisplaySideController else { return @@ -141,20 +141,20 @@ extension SideMenuController { self.centerPanelOverlay.alpha = alpha self.set(statusUnderlayAlpha: alpha) self.sidePanel.frame = destinationFrame - }, completion: { _ in + }, completion: { completion?(updated) }) } - func handleLeftSwipe(){ + @objc func handleLeftSwipe(){ handleHorizontalSwipe(toLeft: true) } - func handleRightSwipe(){ + @objc func handleRightSwipe(){ handleHorizontalSwipe(toLeft: false) } - func handleHorizontalSwipe(toLeft left: Bool) { + @objc func handleHorizontalSwipe(toLeft left: Bool) { if (left && sidePanelPosition.isPositionedLeft) || (!left && !sidePanelPosition.isPositionedLeft) { if sidePanelVisible { diff --git a/Source/SideMenuController+SideUnder.swift b/Source/SideMenuController+SideUnder.swift index 700e1b5..d05c8fd 100644 --- a/Source/SideMenuController+SideUnder.swift +++ b/Source/SideMenuController+SideUnder.swift @@ -47,11 +47,11 @@ extension SideMenuController { centerPanel.addGestureRecognizer(tapRecognizer) } - @inline(__always) func handleCenterPanelPanLeft(_ gesture: UIScreenEdgePanGestureRecognizer) { + @objc @inline(__always) func handleCenterPanelPanLeft(_ gesture: UIScreenEdgePanGestureRecognizer) { handleCenterPanelPan(gesture) } - @inline(__always) func handleCenterPanelPanRight(_ gesture: UIScreenEdgePanGestureRecognizer) { + @objc @inline(__always) func handleCenterPanelPanRight(_ gesture: UIScreenEdgePanGestureRecognizer) { handleCenterPanelPan(gesture) } @@ -92,10 +92,10 @@ extension SideMenuController { let updated = centerPanel.frame != centerPanelFrame - UIView.panelAnimation( duration, animations: { _ in + UIView.panelAnimation( duration, animations: { self.centerPanel.frame = centerPanelFrame self.set(statusUnderlayAlpha: hidden ? 0 : 1) - }) { _ in + }) { if hidden { self.setSideShadow(hidden: hidden) } @@ -103,7 +103,7 @@ extension SideMenuController { } } - func handleCenterPanelPan(_ recognizer: UIPanGestureRecognizer){ + @objc func handleCenterPanelPan(_ recognizer: UIPanGestureRecognizer){ guard canDisplaySideController else { return diff --git a/Source/SideMenuController.swift b/Source/SideMenuController.swift index 69fdaae..461039e 100644 --- a/Source/SideMenuController.swift +++ b/Source/SideMenuController.swift @@ -35,7 +35,7 @@ public extension SideMenuController { /** Toggles the side pannel visible or not. */ - public func toggle() { + @objc public func toggle() { if !transitionInProgress { if !sidePanelVisible { @@ -213,7 +213,7 @@ open class SideMenuController: UIViewController, UIGestureRecognizerDelegate { // MARK: - Configurations - - func repositionViews() { + @objc func repositionViews() { if sidePanelVisible { toggle() @@ -356,7 +356,7 @@ open class SideMenuController: UIViewController, UIGestureRecognizerDelegate { statusBarUnderlay.alpha = alpha } - func handleTap() { + @objc func handleTap() { animate(toReveal: false) } From 324575a69c6554e4c157509c23765a2db9d4c5a9 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Mon, 18 Nov 2019 23:49:02 +0530 Subject: [PATCH 2/2] sbw updated for ios13 --- Source/SideMenuController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/SideMenuController.swift b/Source/SideMenuController.swift index 18919e5..3174870 100644 --- a/Source/SideMenuController.swift +++ b/Source/SideMenuController.swift @@ -398,7 +398,15 @@ open class SideMenuController: UIViewController, UIGestureRecognizerDelegate { let b = "Bar" let w = "Window" - return UIApplication.shared.value(forKey: s+b+w) as? UIWindow + if #available(iOS 13.0, *) { + let statusBar = UIView(frame: UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero) + UIApplication.shared.keyWindow?.addSubview(statusBar) + return statusBar as? UIWindow + } else { + return UIApplication.shared.value(forKey: s+b+w) as? UIWindow + // Fallback on earlier versions + } + } fileprivate var showsStatusUnderlay: Bool {