├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── SHFullscreenPopGestureSwift.podspec ├── SHFullscreenPopGestureSwift └── SHFullscreenPopGesture.swift └── SHFullscreenPopGestureSwiftDemo ├── .DS_Store ├── SHFullscreenPopGestureSwiftDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SHFullscreenPopGestureSwiftDemo ├── AppDelegate.swift ├── Assets.xcassets │ ├── ACE.imageset │ │ ├── ACE.png │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── SHAceViewController.swift ├── SHAceViewController.xib ├── SHNoBarViewController.swift ├── SHNoBarViewController.xib ├── SHNoGestureViewController.swift ├── SHNoGestureViewController.xib ├── SHScrollViewController.swift ├── SHScrollViewController.xib └── ViewController.swift ├── SHFullscreenPopGestureSwiftDemoTests ├── Info.plist └── SHFullscreenPopGestureSwiftDemoTests.swift └── SHFullscreenPopGestureSwiftDemoUITests ├── Info.plist └── SHFullscreenPopGestureSwiftDemoUITests.swift /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShowHandAce/SHFullscreenPopGestureSwift/e06dd0bf030b3eed2cc0edd2b2445afcd9f6f034/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 ShowHandAce 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SHFullscreenPopGestureSwift 2 | FDFullScreenPopGesture Swift 重制版. 3 | 4 | # 感谢 5 | **本代码仅出于学习目的,思路与方法出自 [FDFullScreenPopGesture](https://github.com/forkingdog/FDFullscreenPopGesture) 与 [FDFullScreenPopGestureSwift](https://github.com/Minlison/FDFullScreenPopGestureSwift) .特此声明并表示感谢.** 6 | 7 | 如有问题请批评指正. 8 | 9 | # 使用 10 | * Swift 4 中 `initialze` 方法被禁用.需在 `application(_:didFinishLaunchingWithOptions:)` 方法中调用 `SHFullscreenPopGesture.configure()` 来启用 Method swizzling. 11 | 12 | ``` swift 13 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 14 | // Override point for customization after application launch. 15 | 16 | // 启用 17 | SHFullscreenPopGesture.configure() 18 | 19 | return true 20 | } 21 | ``` 22 | 23 | * 跳转至有 **UIScrollView** 的控制器时,需要在 **UIScrollView** 内部完成返回手势,只需如下设置: 24 | 25 | ``` swift 26 | scrollView.sh_scrollViewPopGestureRecognizerEnable = true 27 | ``` 28 | 29 | * 其余使用方法与 **[FDFullScreenPopGesture](https://github.com/forkingdog/FDFullscreenPopGesture)** 一致. 30 | 31 | > * 如果项目使用 Swift4 以下的版本,依然可以使用 本库1.1版本实现无代码设置的全屏返回.请在 `Podfile.lock`确认本库真实版本,并在 pod 工程 SHFullscreenPopGestureSwift target 的 build setting 中确认本库使用低于 Swift4 的版本编译. 32 | > * 如果项目使用 Swift4 请使用最新版本,并在 AppDelegate 中设置.(最新版本为1.2.1 不要纠结版本号为什么这么乱...) 33 | 34 | # CocoaPods 安装 35 | ``` ruby 36 | pod 'SHFullscreenPopGestureSwift' 37 | ``` 38 | 39 | # License 40 | MIT -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwift.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint SHFullscreenPopGestureSwift.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 12 | # 13 | # These will help people to find your library, and whilst it 14 | # can feel like a chore to fill in it's definitely to your advantage. The 15 | # summary should be tweet-length, and the description more in depth. 16 | # 17 | 18 | s.name = "SHFullscreenPopGestureSwift" 19 | s.version = "1.2.1" 20 | s.summary = "FDFullScreenPopGesture Swift 重制版." 21 | 22 | # This description is used to generate tags and improve search results. 23 | # * Think: What does it do? Why did you write it? What is the focus? 24 | # * Try to keep it short, snappy and to the point. 25 | # * Write the description between the DESC delimiters below. 26 | # * Finally, don't worry about the indent, CocoaPods strips it! 27 | s.description = "FDFullScreenPopGesture Swift 重制版.Just pod in 1 file and call 1 function." 28 | 29 | s.homepage = "https://github.com/ShowHandAce/SHFullscreenPopGestureSwift" 30 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 31 | 32 | 33 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 34 | # 35 | # Licensing your code is important. See http://choosealicense.com for more info. 36 | # CocoaPods will detect a license file if there is a named LICENSE* 37 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 38 | # 39 | 40 | # s.license = "MIT (example)" 41 | s.license = { :type => "MIT", :file => "LICENSE" } 42 | 43 | 44 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 45 | # 46 | # Specify the authors of the library, with email addresses. Email addresses 47 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 48 | # accepts just a name if you'd rather not provide an email address. 49 | # 50 | # Specify a social_media_url where others can refer to, for example a twitter 51 | # profile URL. 52 | # 53 | 54 | s.author = { "ShowHandAce" => "https://github.com/ShowHandAce" } 55 | # Or just: s.author = "ShowHandAce" 56 | # s.authors = { "ShowHandAce" => "email@address.com" } 57 | # s.social_media_url = "http://twitter.com/ShowHandAce" 58 | 59 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 60 | # 61 | # If this Pod runs only on iOS or OS X, then specify the platform and 62 | # the deployment target. You can optionally include the target after the platform. 63 | # 64 | 65 | # s.platform = :ios 66 | s.platform = :ios, "8.0" 67 | 68 | # When using multiple platforms 69 | # s.ios.deployment_target = "5.0" 70 | # s.osx.deployment_target = "10.7" 71 | # s.watchos.deployment_target = "2.0" 72 | # s.tvos.deployment_target = "9.0" 73 | 74 | 75 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 76 | # 77 | # Specify the location from where the source should be retrieved. 78 | # Supports git, hg, bzr, svn and HTTP. 79 | # 80 | 81 | s.source = { :git => "https://github.com/ShowHandAce/SHFullscreenPopGestureSwift.git", :tag => s.version } 82 | 83 | 84 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 85 | # 86 | # CocoaPods is smart about how it includes source code. For source files 87 | # giving a folder will include any swift, h, m, mm, c & cpp files. 88 | # For header files it will include any header in the folder. 89 | # Not including the public_header_files will make all headers public. 90 | # 91 | 92 | s.source_files = "SHFullscreenPopGestureSwift/*.swift" 93 | # s.exclude_files = "Classes/Exclude" 94 | 95 | # s.public_header_files = "Classes/**/*.h" 96 | 97 | 98 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 99 | # 100 | # A list of resources included with the Pod. These are copied into the 101 | # target bundle with a build phase script. Anything else will be cleaned. 102 | # You can preserve files from being cleaned, please don't preserve 103 | # non-essential files like tests, examples and documentation. 104 | # 105 | 106 | # s.resource = "icon.png" 107 | # s.resources = "Resources/*.png" 108 | 109 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 110 | 111 | 112 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 113 | # 114 | # Link your library with frameworks, or libraries. Libraries do not include 115 | # the lib prefix of their name. 116 | # 117 | 118 | # s.framework = "SomeFramework" 119 | # s.frameworks = "SomeFramework", "AnotherFramework" 120 | 121 | # s.library = "iconv" 122 | # s.libraries = "iconv", "xml2" 123 | 124 | 125 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 126 | # 127 | # If your library depends on compiler flags you can set them in the xcconfig hash 128 | # where they will only apply to your library. If you depend on other Podspecs 129 | # you can include multiple dependencies to ensure it works. 130 | 131 | s.requires_arc = true 132 | 133 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 134 | # s.dependency "JSONKit", "~> 1.4" 135 | 136 | end 137 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwift/SHFullscreenPopGesture.swift: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright © 2017年 ShowHandAce 4 | // 5 | 6 | /** 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | */ 13 | 14 | import UIKit 15 | 16 | open class SHFullscreenPopGesture { 17 | 18 | open class func configure() { 19 | 20 | UINavigationController.sh_nav_initialize() 21 | UIViewController.sh_initialize() 22 | } 23 | 24 | } 25 | 26 | extension UINavigationController { 27 | 28 | private var sh_popGestureRecognizerDelegate: _SHFullscreenPopGestureRecognizerDelegate { 29 | guard let delegate = objc_getAssociatedObject(self, RuntimeKey.KEY_sh_popGestureRecognizerDelegate!) as? _SHFullscreenPopGestureRecognizerDelegate else { 30 | let popDelegate = _SHFullscreenPopGestureRecognizerDelegate() 31 | popDelegate.navigationController = self 32 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_popGestureRecognizerDelegate!, popDelegate, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 33 | return popDelegate 34 | } 35 | return delegate 36 | } 37 | 38 | open class func sh_nav_initialize() { 39 | // Inject "-pushViewController:animated:" 40 | DispatchQueue.once(token: "com.UINavigationController.MethodSwizzling", block: { 41 | let originalMethod = class_getInstanceMethod(self, #selector(pushViewController(_:animated:))) 42 | let swizzledMethod = class_getInstanceMethod(self, #selector(sh_pushViewController(_:animated:))) 43 | method_exchangeImplementations(originalMethod!, swizzledMethod!) 44 | }) 45 | } 46 | 47 | // override open class func initialize() { 48 | // // Inject "-pushViewController:animated:" 49 | // DispatchQueue.once(token: "com.UINavigationController.MethodSwizzling", block: { 50 | // let originalMethod = class_getInstanceMethod(self, #selector(pushViewController(_:animated:))) 51 | // let swizzledMethod = class_getInstanceMethod(self, #selector(sh_pushViewController(_:animated:))) 52 | // method_exchangeImplementations(originalMethod!, swizzledMethod!) 53 | // }) 54 | // } 55 | 56 | @objc private func sh_pushViewController(_ viewController: UIViewController, animated: Bool) { 57 | 58 | if self.interactivePopGestureRecognizer?.view?.gestureRecognizers?.contains(self.sh_fullscreenPopGestureRecognizer) == false { 59 | 60 | // Add our own gesture recognizer to where the onboard screen edge pan gesture recognizer is attached to. 61 | self.interactivePopGestureRecognizer?.view?.addGestureRecognizer(self.sh_fullscreenPopGestureRecognizer) 62 | 63 | // Forward the gesture events to the private handler of the onboard gesture recognizer. 64 | let internalTargets = self.interactivePopGestureRecognizer?.value(forKey: "targets") as? Array 65 | let internalTarget = internalTargets?.first?.value(forKey: "target") 66 | let internalAction = NSSelectorFromString("handleNavigationTransition:") 67 | if let target = internalTarget { 68 | self.sh_fullscreenPopGestureRecognizer.delegate = self.sh_popGestureRecognizerDelegate 69 | self.sh_fullscreenPopGestureRecognizer.addTarget(target, action: internalAction) 70 | 71 | // Disable the onboard gesture recognizer. 72 | self.interactivePopGestureRecognizer?.isEnabled = false 73 | } 74 | } 75 | 76 | // Handle perferred navigation bar appearance. 77 | self.sh_setupViewControllerBasedNavigationBarAppearanceIfNeeded(viewController) 78 | 79 | // Forward to primary implementation. 80 | self.sh_pushViewController(viewController, animated: animated) 81 | } 82 | 83 | private func sh_setupViewControllerBasedNavigationBarAppearanceIfNeeded(_ appearingViewController: UIViewController) { 84 | 85 | if !self.sh_viewControllerBasedNavigationBarAppearanceEnabled { 86 | return 87 | } 88 | 89 | let blockContainer = _SHViewControllerWillAppearInjectBlockContainer() { [weak self] (_ viewController: UIViewController, _ animated: Bool) -> Void in 90 | self?.setNavigationBarHidden(viewController.sh_prefersNavigationBarHidden, animated: animated) 91 | } 92 | 93 | // Setup will appear inject block to appearing view controller. 94 | // Setup disappearing view controller as well, because not every view controller is added into 95 | // stack by pushing, maybe by "-setViewControllers:". 96 | appearingViewController.sh_willAppearInjectBlockContainer = blockContainer 97 | let disappearingViewController = self.viewControllers.last 98 | if let vc = disappearingViewController { 99 | if vc.sh_willAppearInjectBlockContainer == nil { 100 | vc.sh_willAppearInjectBlockContainer = blockContainer 101 | } 102 | } 103 | } 104 | 105 | /// The gesture recognizer that actually handles interactive pop. 106 | public var sh_fullscreenPopGestureRecognizer: UIPanGestureRecognizer { 107 | guard let pan = objc_getAssociatedObject(self, RuntimeKey.KEY_sh_fullscreenPopGestureRecognizer!) as? UIPanGestureRecognizer else { 108 | let panGesture = UIPanGestureRecognizer() 109 | panGesture.maximumNumberOfTouches = 1; 110 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_fullscreenPopGestureRecognizer!, panGesture, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 111 | 112 | return panGesture 113 | } 114 | return pan 115 | } 116 | 117 | /// A view controller is able to control navigation bar's appearance by itself, 118 | /// rather than a global way, checking "fd_prefersNavigationBarHidden" property. 119 | /// Default to true, disable it if you don't want so. 120 | public var sh_viewControllerBasedNavigationBarAppearanceEnabled: Bool { 121 | get { 122 | guard let bools = objc_getAssociatedObject(self, RuntimeKey.KEY_sh_viewControllerBasedNavigationBarAppearanceEnabled!) as? Bool else { 123 | self.sh_viewControllerBasedNavigationBarAppearanceEnabled = true 124 | return true 125 | } 126 | return bools 127 | } 128 | set { 129 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_viewControllerBasedNavigationBarAppearanceEnabled!, newValue, .OBJC_ASSOCIATION_ASSIGN) 130 | } 131 | } 132 | } 133 | 134 | fileprivate typealias _SHViewControllerWillAppearInjectBlock = (_ viewController: UIViewController, _ animated: Bool) -> Void 135 | 136 | fileprivate class _SHViewControllerWillAppearInjectBlockContainer { 137 | var block: _SHViewControllerWillAppearInjectBlock? 138 | init(_ block: @escaping _SHViewControllerWillAppearInjectBlock) { 139 | self.block = block 140 | } 141 | } 142 | 143 | extension UIViewController { 144 | 145 | fileprivate var sh_willAppearInjectBlockContainer: _SHViewControllerWillAppearInjectBlockContainer? { 146 | get { 147 | return objc_getAssociatedObject(self, RuntimeKey.KEY_sh_willAppearInjectBlockContainer!) as? _SHViewControllerWillAppearInjectBlockContainer 148 | } 149 | set { 150 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_willAppearInjectBlockContainer!, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 151 | } 152 | } 153 | 154 | open class func sh_initialize() { 155 | 156 | DispatchQueue.once(token: "com.UIViewController.MethodSwizzling", block: { 157 | let originalMethod = class_getInstanceMethod(self, #selector(viewWillAppear(_:))) 158 | let swizzledMethod = class_getInstanceMethod(self, #selector(sh_viewWillAppear(_:))) 159 | method_exchangeImplementations(originalMethod!, swizzledMethod!) 160 | }) 161 | } 162 | 163 | // override open class func initialize() { 164 | // 165 | // DispatchQueue.once(token: "com.UIViewController.MethodSwizzling", block: { 166 | // let originalMethod = class_getInstanceMethod(self, #selector(viewWillAppear(_:))) 167 | // let swizzledMethod = class_getInstanceMethod(self, #selector(sh_viewWillAppear(_:))) 168 | // method_exchangeImplementations(originalMethod!, swizzledMethod!) 169 | // }) 170 | // } 171 | 172 | @objc private func sh_viewWillAppear(_ animated: Bool) { 173 | // Forward to primary implementation. 174 | self.sh_viewWillAppear(animated) 175 | 176 | if let block = self.sh_willAppearInjectBlockContainer?.block { 177 | block(self, animated) 178 | } 179 | } 180 | 181 | /// Whether the interactive pop gesture is disabled when contained in a navigation stack. 182 | public var sh_interactivePopDisabled: Bool { 183 | get { 184 | guard let bools = objc_getAssociatedObject(self, RuntimeKey.KEY_sh_interactivePopDisabled!) as? Bool else { 185 | return false 186 | } 187 | return bools 188 | } 189 | set { 190 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_interactivePopDisabled!, newValue, .OBJC_ASSOCIATION_ASSIGN) 191 | } 192 | } 193 | 194 | /// Indicate this view controller prefers its navigation bar hidden or not, 195 | /// checked when view controller based navigation bar's appearance is enabled. 196 | /// Default to false, bars are more likely to show. 197 | public var sh_prefersNavigationBarHidden: Bool { 198 | get { 199 | guard let bools = objc_getAssociatedObject(self, RuntimeKey.KEY_sh_prefersNavigationBarHidden!) as? Bool else { 200 | return false 201 | } 202 | return bools 203 | } 204 | set { 205 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_prefersNavigationBarHidden!, newValue, .OBJC_ASSOCIATION_ASSIGN) 206 | } 207 | } 208 | 209 | /// Max allowed initial distance to left edge when you begin the interactive pop 210 | /// gesture. 0 by default, which means it will ignore this limit. 211 | public var sh_interactivePopMaxAllowedInitialDistanceToLeftEdge: Double { 212 | get { 213 | guard let doubleNum = objc_getAssociatedObject(self, RuntimeKey.KEY_sh_interactivePopMaxAllowedInitialDistanceToLeftEdge!) as? Double else { 214 | return 0.0 215 | } 216 | return doubleNum 217 | } 218 | set { 219 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_interactivePopMaxAllowedInitialDistanceToLeftEdge!, newValue, .OBJC_ASSOCIATION_COPY) 220 | } 221 | } 222 | } 223 | 224 | private class _SHFullscreenPopGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate { 225 | 226 | weak var navigationController: UINavigationController? 227 | 228 | func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { 229 | 230 | guard let navigationC = self.navigationController else { 231 | return false 232 | } 233 | 234 | // Ignore when no view controller is pushed into the navigation stack. 235 | guard navigationC.viewControllers.count > 1 else { 236 | return false 237 | } 238 | 239 | // Disable when the active view controller doesn't allow interactive pop. 240 | guard let topViewController = navigationC.viewControllers.last else { 241 | return false 242 | } 243 | guard !topViewController.sh_interactivePopDisabled else { 244 | return false 245 | } 246 | 247 | // Ignore pan gesture when the navigation controller is currently in transition. 248 | guard let trasition = navigationC.value(forKey: "_isTransitioning") as? Bool else { 249 | return false 250 | } 251 | guard !trasition else { 252 | return false 253 | } 254 | 255 | guard let panGesture = gestureRecognizer as? UIPanGestureRecognizer else { 256 | return false 257 | } 258 | 259 | // Ignore when the beginning location is beyond max allowed initial distance to left edge. 260 | let beginningLocation = panGesture.location(in: panGesture.view) 261 | let maxAllowedInitialDistance = topViewController.sh_interactivePopMaxAllowedInitialDistanceToLeftEdge 262 | guard maxAllowedInitialDistance <= 0 || Double(beginningLocation.x) <= maxAllowedInitialDistance else { 263 | return false 264 | } 265 | 266 | // Prevent calling the handler when the gesture begins in an opposite direction. 267 | let translation = panGesture.translation(in: panGesture.view) 268 | guard translation.x > 0 else { 269 | return false 270 | } 271 | 272 | return true 273 | } 274 | } 275 | 276 | fileprivate struct RuntimeKey { 277 | static let KEY_sh_willAppearInjectBlockContainer 278 | = UnsafeRawPointer(bitPattern: "KEY_sh_willAppearInjectBlockContainer".hashValue) 279 | static let KEY_sh_interactivePopDisabled 280 | = UnsafeRawPointer(bitPattern: "KEY_sh_interactivePopDisabled".hashValue) 281 | static let KEY_sh_prefersNavigationBarHidden 282 | = UnsafeRawPointer(bitPattern: "KEY_sh_prefersNavigationBarHidden".hashValue) 283 | static let KEY_sh_interactivePopMaxAllowedInitialDistanceToLeftEdge 284 | = UnsafeRawPointer(bitPattern: "KEY_sh_interactivePopMaxAllowedInitialDistanceToLeftEdge".hashValue) 285 | static let KEY_sh_fullscreenPopGestureRecognizer 286 | = UnsafeRawPointer(bitPattern: "KEY_sh_fullscreenPopGestureRecognizer".hashValue) 287 | static let KEY_sh_popGestureRecognizerDelegate 288 | = UnsafeRawPointer(bitPattern: "KEY_sh_popGestureRecognizerDelegate".hashValue) 289 | static let KEY_sh_viewControllerBasedNavigationBarAppearanceEnabled 290 | = UnsafeRawPointer(bitPattern: "KEY_sh_viewControllerBasedNavigationBarAppearanceEnabled".hashValue) 291 | static let KEY_sh_scrollViewPopGestureRecognizerEnable 292 | = UnsafeRawPointer(bitPattern: "KEY_sh_scrollViewPopGestureRecognizerEnable".hashValue) 293 | } 294 | 295 | extension UIScrollView: UIGestureRecognizerDelegate { 296 | 297 | public var sh_scrollViewPopGestureRecognizerEnable: Bool { 298 | get { 299 | guard let bools = objc_getAssociatedObject(self, RuntimeKey.KEY_sh_scrollViewPopGestureRecognizerEnable!) as? Bool else { 300 | return false 301 | } 302 | return bools 303 | } 304 | set { 305 | objc_setAssociatedObject(self, RuntimeKey.KEY_sh_scrollViewPopGestureRecognizerEnable!, newValue, .OBJC_ASSOCIATION_ASSIGN) 306 | } 307 | } 308 | 309 | //UIGestureRecognizerDelegate 310 | public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { 311 | if self.sh_scrollViewPopGestureRecognizerEnable, self.contentOffset.x <= 0, let gestureDelegate = otherGestureRecognizer.delegate { 312 | if gestureDelegate.isKind(of: _SHFullscreenPopGestureRecognizerDelegate.self) { 313 | return true 314 | } 315 | } 316 | return false 317 | } 318 | } 319 | 320 | fileprivate extension DispatchQueue { 321 | 322 | private static var _onceTracker = [String]() 323 | 324 | /** 325 | Executes a block of code, associated with a unique token, only once. The code is thread safe and will 326 | only execute the code once even in the presence of multithreaded calls. 327 | 328 | - parameter token: A unique reverse DNS style name such as com.vectorform. or a GUID 329 | - parameter block: Block to execute once 330 | */ 331 | class func once(token: String, block: () -> Void) { 332 | objc_sync_enter(self) 333 | defer { objc_sync_exit(self) } 334 | 335 | if _onceTracker.contains(token) { 336 | return 337 | } 338 | 339 | _onceTracker.append(token) 340 | block() 341 | } 342 | } 343 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShowHandAce/SHFullscreenPopGestureSwift/e06dd0bf030b3eed2cc0edd2b2445afcd9f6f034/SHFullscreenPopGestureSwiftDemo/.DS_Store -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B93AE4CF1F20AE0F005084BD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE4CE1F20AE0F005084BD /* AppDelegate.swift */; }; 11 | B93AE4D11F20AE0F005084BD /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE4D01F20AE0F005084BD /* ViewController.swift */; }; 12 | B93AE4D41F20AE0F005084BD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B93AE4D21F20AE0F005084BD /* Main.storyboard */; }; 13 | B93AE4D61F20AE10005084BD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B93AE4D51F20AE0F005084BD /* Assets.xcassets */; }; 14 | B93AE4D91F20AE10005084BD /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B93AE4D71F20AE10005084BD /* LaunchScreen.storyboard */; }; 15 | B93AE4E41F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE4E31F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.swift */; }; 16 | B93AE4EF1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE4EE1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.swift */; }; 17 | B93AE4FE1F20AE60005084BD /* SHFullscreenPopGesture.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE4FD1F20AE60005084BD /* SHFullscreenPopGesture.swift */; }; 18 | B93AE5031F20B6A9005084BD /* SHAceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE5011F20B6A9005084BD /* SHAceViewController.swift */; }; 19 | B93AE5041F20B6A9005084BD /* SHAceViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B93AE5021F20B6A9005084BD /* SHAceViewController.xib */; }; 20 | B93AE5071F20BB69005084BD /* SHNoBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE5051F20BB69005084BD /* SHNoBarViewController.swift */; }; 21 | B93AE5081F20BB69005084BD /* SHNoBarViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B93AE5061F20BB69005084BD /* SHNoBarViewController.xib */; }; 22 | B93AE50B1F219F0D005084BD /* SHNoGestureViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE5091F219F0D005084BD /* SHNoGestureViewController.swift */; }; 23 | B93AE50C1F219F0D005084BD /* SHNoGestureViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B93AE50A1F219F0D005084BD /* SHNoGestureViewController.xib */; }; 24 | B93AE50F1F21A2C8005084BD /* SHScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B93AE50D1F21A2C8005084BD /* SHScrollViewController.swift */; }; 25 | B93AE5101F21A2C8005084BD /* SHScrollViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B93AE50E1F21A2C8005084BD /* SHScrollViewController.xib */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | B93AE4E01F20AE10005084BD /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = B93AE4C31F20AE0F005084BD /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = B93AE4CA1F20AE0F005084BD; 34 | remoteInfo = SHFullscreenPopGestureSwiftDemo; 35 | }; 36 | B93AE4EB1F20AE10005084BD /* PBXContainerItemProxy */ = { 37 | isa = PBXContainerItemProxy; 38 | containerPortal = B93AE4C31F20AE0F005084BD /* Project object */; 39 | proxyType = 1; 40 | remoteGlobalIDString = B93AE4CA1F20AE0F005084BD; 41 | remoteInfo = SHFullscreenPopGestureSwiftDemo; 42 | }; 43 | /* End PBXContainerItemProxy section */ 44 | 45 | /* Begin PBXFileReference section */ 46 | B93AE4CB1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SHFullscreenPopGestureSwiftDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | B93AE4CE1F20AE0F005084BD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 48 | B93AE4D01F20AE0F005084BD /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 49 | B93AE4D31F20AE0F005084BD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | B93AE4D51F20AE0F005084BD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 51 | B93AE4D81F20AE10005084BD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 52 | B93AE4DA1F20AE10005084BD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | B93AE4DF1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SHFullscreenPopGestureSwiftDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | B93AE4E31F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHFullscreenPopGestureSwiftDemoTests.swift; sourceTree = ""; }; 55 | B93AE4E51F20AE10005084BD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | B93AE4EA1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SHFullscreenPopGestureSwiftDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | B93AE4EE1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHFullscreenPopGestureSwiftDemoUITests.swift; sourceTree = ""; }; 58 | B93AE4F01F20AE10005084BD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 59 | B93AE4FD1F20AE60005084BD /* SHFullscreenPopGesture.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHFullscreenPopGesture.swift; sourceTree = ""; }; 60 | B93AE5011F20B6A9005084BD /* SHAceViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHAceViewController.swift; sourceTree = ""; }; 61 | B93AE5021F20B6A9005084BD /* SHAceViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SHAceViewController.xib; sourceTree = ""; }; 62 | B93AE5051F20BB69005084BD /* SHNoBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHNoBarViewController.swift; sourceTree = ""; }; 63 | B93AE5061F20BB69005084BD /* SHNoBarViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SHNoBarViewController.xib; sourceTree = ""; }; 64 | B93AE5091F219F0D005084BD /* SHNoGestureViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHNoGestureViewController.swift; sourceTree = ""; }; 65 | B93AE50A1F219F0D005084BD /* SHNoGestureViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SHNoGestureViewController.xib; sourceTree = ""; }; 66 | B93AE50D1F21A2C8005084BD /* SHScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SHScrollViewController.swift; sourceTree = ""; }; 67 | B93AE50E1F21A2C8005084BD /* SHScrollViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SHScrollViewController.xib; sourceTree = ""; }; 68 | /* End PBXFileReference section */ 69 | 70 | /* Begin PBXFrameworksBuildPhase section */ 71 | B93AE4C81F20AE0F005084BD /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | B93AE4DC1F20AE10005084BD /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | B93AE4E71F20AE10005084BD /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | /* End PBXFrameworksBuildPhase section */ 93 | 94 | /* Begin PBXGroup section */ 95 | B93AE4C21F20AE0F005084BD = { 96 | isa = PBXGroup; 97 | children = ( 98 | B93AE4CD1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo */, 99 | B93AE4E21F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests */, 100 | B93AE4ED1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests */, 101 | B93AE4CC1F20AE0F005084BD /* Products */, 102 | ); 103 | sourceTree = ""; 104 | }; 105 | B93AE4CC1F20AE0F005084BD /* Products */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | B93AE4CB1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo.app */, 109 | B93AE4DF1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.xctest */, 110 | B93AE4EA1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.xctest */, 111 | ); 112 | name = Products; 113 | sourceTree = ""; 114 | }; 115 | B93AE4CD1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | B93AE4FC1F20AE44005084BD /* SHFullscreenPopGestureSwift */, 119 | B93AE4CE1F20AE0F005084BD /* AppDelegate.swift */, 120 | B93AE5091F219F0D005084BD /* SHNoGestureViewController.swift */, 121 | B93AE50A1F219F0D005084BD /* SHNoGestureViewController.xib */, 122 | B93AE50D1F21A2C8005084BD /* SHScrollViewController.swift */, 123 | B93AE50E1F21A2C8005084BD /* SHScrollViewController.xib */, 124 | B93AE5051F20BB69005084BD /* SHNoBarViewController.swift */, 125 | B93AE5061F20BB69005084BD /* SHNoBarViewController.xib */, 126 | B93AE5011F20B6A9005084BD /* SHAceViewController.swift */, 127 | B93AE5021F20B6A9005084BD /* SHAceViewController.xib */, 128 | B93AE4D01F20AE0F005084BD /* ViewController.swift */, 129 | B93AE4D21F20AE0F005084BD /* Main.storyboard */, 130 | B93AE4D51F20AE0F005084BD /* Assets.xcassets */, 131 | B93AE4D71F20AE10005084BD /* LaunchScreen.storyboard */, 132 | B93AE4DA1F20AE10005084BD /* Info.plist */, 133 | ); 134 | path = SHFullscreenPopGestureSwiftDemo; 135 | sourceTree = ""; 136 | }; 137 | B93AE4E21F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | B93AE4E31F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.swift */, 141 | B93AE4E51F20AE10005084BD /* Info.plist */, 142 | ); 143 | path = SHFullscreenPopGestureSwiftDemoTests; 144 | sourceTree = ""; 145 | }; 146 | B93AE4ED1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | B93AE4EE1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.swift */, 150 | B93AE4F01F20AE10005084BD /* Info.plist */, 151 | ); 152 | path = SHFullscreenPopGestureSwiftDemoUITests; 153 | sourceTree = ""; 154 | }; 155 | B93AE4FC1F20AE44005084BD /* SHFullscreenPopGestureSwift */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | B93AE4FD1F20AE60005084BD /* SHFullscreenPopGesture.swift */, 159 | ); 160 | name = SHFullscreenPopGestureSwift; 161 | path = ../../SHFullscreenPopGestureSwift; 162 | sourceTree = ""; 163 | }; 164 | /* End PBXGroup section */ 165 | 166 | /* Begin PBXNativeTarget section */ 167 | B93AE4CA1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo */ = { 168 | isa = PBXNativeTarget; 169 | buildConfigurationList = B93AE4F31F20AE10005084BD /* Build configuration list for PBXNativeTarget "SHFullscreenPopGestureSwiftDemo" */; 170 | buildPhases = ( 171 | B93AE4C71F20AE0F005084BD /* Sources */, 172 | B93AE4C81F20AE0F005084BD /* Frameworks */, 173 | B93AE4C91F20AE0F005084BD /* Resources */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | ); 179 | name = SHFullscreenPopGestureSwiftDemo; 180 | productName = SHFullscreenPopGestureSwiftDemo; 181 | productReference = B93AE4CB1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo.app */; 182 | productType = "com.apple.product-type.application"; 183 | }; 184 | B93AE4DE1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests */ = { 185 | isa = PBXNativeTarget; 186 | buildConfigurationList = B93AE4F61F20AE10005084BD /* Build configuration list for PBXNativeTarget "SHFullscreenPopGestureSwiftDemoTests" */; 187 | buildPhases = ( 188 | B93AE4DB1F20AE10005084BD /* Sources */, 189 | B93AE4DC1F20AE10005084BD /* Frameworks */, 190 | B93AE4DD1F20AE10005084BD /* Resources */, 191 | ); 192 | buildRules = ( 193 | ); 194 | dependencies = ( 195 | B93AE4E11F20AE10005084BD /* PBXTargetDependency */, 196 | ); 197 | name = SHFullscreenPopGestureSwiftDemoTests; 198 | productName = SHFullscreenPopGestureSwiftDemoTests; 199 | productReference = B93AE4DF1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.xctest */; 200 | productType = "com.apple.product-type.bundle.unit-test"; 201 | }; 202 | B93AE4E91F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests */ = { 203 | isa = PBXNativeTarget; 204 | buildConfigurationList = B93AE4F91F20AE10005084BD /* Build configuration list for PBXNativeTarget "SHFullscreenPopGestureSwiftDemoUITests" */; 205 | buildPhases = ( 206 | B93AE4E61F20AE10005084BD /* Sources */, 207 | B93AE4E71F20AE10005084BD /* Frameworks */, 208 | B93AE4E81F20AE10005084BD /* Resources */, 209 | ); 210 | buildRules = ( 211 | ); 212 | dependencies = ( 213 | B93AE4EC1F20AE10005084BD /* PBXTargetDependency */, 214 | ); 215 | name = SHFullscreenPopGestureSwiftDemoUITests; 216 | productName = SHFullscreenPopGestureSwiftDemoUITests; 217 | productReference = B93AE4EA1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.xctest */; 218 | productType = "com.apple.product-type.bundle.ui-testing"; 219 | }; 220 | /* End PBXNativeTarget section */ 221 | 222 | /* Begin PBXProject section */ 223 | B93AE4C31F20AE0F005084BD /* Project object */ = { 224 | isa = PBXProject; 225 | attributes = { 226 | CLASSPREFIX = SH; 227 | LastSwiftUpdateCheck = 0810; 228 | LastUpgradeCheck = 0810; 229 | ORGANIZATIONNAME = ShowHandAce; 230 | TargetAttributes = { 231 | B93AE4CA1F20AE0F005084BD = { 232 | CreatedOnToolsVersion = 8.1; 233 | DevelopmentTeam = GH3WD8CYKW; 234 | ProvisioningStyle = Manual; 235 | }; 236 | B93AE4DE1F20AE10005084BD = { 237 | CreatedOnToolsVersion = 8.1; 238 | ProvisioningStyle = Automatic; 239 | TestTargetID = B93AE4CA1F20AE0F005084BD; 240 | }; 241 | B93AE4E91F20AE10005084BD = { 242 | CreatedOnToolsVersion = 8.1; 243 | ProvisioningStyle = Automatic; 244 | TestTargetID = B93AE4CA1F20AE0F005084BD; 245 | }; 246 | }; 247 | }; 248 | buildConfigurationList = B93AE4C61F20AE0F005084BD /* Build configuration list for PBXProject "SHFullscreenPopGestureSwiftDemo" */; 249 | compatibilityVersion = "Xcode 3.2"; 250 | developmentRegion = English; 251 | hasScannedForEncodings = 0; 252 | knownRegions = ( 253 | en, 254 | Base, 255 | ); 256 | mainGroup = B93AE4C21F20AE0F005084BD; 257 | productRefGroup = B93AE4CC1F20AE0F005084BD /* Products */; 258 | projectDirPath = ""; 259 | projectRoot = ""; 260 | targets = ( 261 | B93AE4CA1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo */, 262 | B93AE4DE1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests */, 263 | B93AE4E91F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests */, 264 | ); 265 | }; 266 | /* End PBXProject section */ 267 | 268 | /* Begin PBXResourcesBuildPhase section */ 269 | B93AE4C91F20AE0F005084BD /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | B93AE4D91F20AE10005084BD /* LaunchScreen.storyboard in Resources */, 274 | B93AE4D61F20AE10005084BD /* Assets.xcassets in Resources */, 275 | B93AE50C1F219F0D005084BD /* SHNoGestureViewController.xib in Resources */, 276 | B93AE5101F21A2C8005084BD /* SHScrollViewController.xib in Resources */, 277 | B93AE4D41F20AE0F005084BD /* Main.storyboard in Resources */, 278 | B93AE5081F20BB69005084BD /* SHNoBarViewController.xib in Resources */, 279 | B93AE5041F20B6A9005084BD /* SHAceViewController.xib in Resources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | B93AE4DD1F20AE10005084BD /* Resources */ = { 284 | isa = PBXResourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | B93AE4E81F20AE10005084BD /* Resources */ = { 291 | isa = PBXResourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | /* End PBXResourcesBuildPhase section */ 298 | 299 | /* Begin PBXSourcesBuildPhase section */ 300 | B93AE4C71F20AE0F005084BD /* Sources */ = { 301 | isa = PBXSourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | B93AE50B1F219F0D005084BD /* SHNoGestureViewController.swift in Sources */, 305 | B93AE4FE1F20AE60005084BD /* SHFullscreenPopGesture.swift in Sources */, 306 | B93AE5071F20BB69005084BD /* SHNoBarViewController.swift in Sources */, 307 | B93AE50F1F21A2C8005084BD /* SHScrollViewController.swift in Sources */, 308 | B93AE4D11F20AE0F005084BD /* ViewController.swift in Sources */, 309 | B93AE4CF1F20AE0F005084BD /* AppDelegate.swift in Sources */, 310 | B93AE5031F20B6A9005084BD /* SHAceViewController.swift in Sources */, 311 | ); 312 | runOnlyForDeploymentPostprocessing = 0; 313 | }; 314 | B93AE4DB1F20AE10005084BD /* Sources */ = { 315 | isa = PBXSourcesBuildPhase; 316 | buildActionMask = 2147483647; 317 | files = ( 318 | B93AE4E41F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoTests.swift in Sources */, 319 | ); 320 | runOnlyForDeploymentPostprocessing = 0; 321 | }; 322 | B93AE4E61F20AE10005084BD /* Sources */ = { 323 | isa = PBXSourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | B93AE4EF1F20AE10005084BD /* SHFullscreenPopGestureSwiftDemoUITests.swift in Sources */, 327 | ); 328 | runOnlyForDeploymentPostprocessing = 0; 329 | }; 330 | /* End PBXSourcesBuildPhase section */ 331 | 332 | /* Begin PBXTargetDependency section */ 333 | B93AE4E11F20AE10005084BD /* PBXTargetDependency */ = { 334 | isa = PBXTargetDependency; 335 | target = B93AE4CA1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo */; 336 | targetProxy = B93AE4E01F20AE10005084BD /* PBXContainerItemProxy */; 337 | }; 338 | B93AE4EC1F20AE10005084BD /* PBXTargetDependency */ = { 339 | isa = PBXTargetDependency; 340 | target = B93AE4CA1F20AE0F005084BD /* SHFullscreenPopGestureSwiftDemo */; 341 | targetProxy = B93AE4EB1F20AE10005084BD /* PBXContainerItemProxy */; 342 | }; 343 | /* End PBXTargetDependency section */ 344 | 345 | /* Begin PBXVariantGroup section */ 346 | B93AE4D21F20AE0F005084BD /* Main.storyboard */ = { 347 | isa = PBXVariantGroup; 348 | children = ( 349 | B93AE4D31F20AE0F005084BD /* Base */, 350 | ); 351 | name = Main.storyboard; 352 | sourceTree = ""; 353 | }; 354 | B93AE4D71F20AE10005084BD /* LaunchScreen.storyboard */ = { 355 | isa = PBXVariantGroup; 356 | children = ( 357 | B93AE4D81F20AE10005084BD /* Base */, 358 | ); 359 | name = LaunchScreen.storyboard; 360 | sourceTree = ""; 361 | }; 362 | /* End PBXVariantGroup section */ 363 | 364 | /* Begin XCBuildConfiguration section */ 365 | B93AE4F11F20AE10005084BD /* Debug */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ALWAYS_SEARCH_USER_PATHS = NO; 369 | CLANG_ANALYZER_NONNULL = YES; 370 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 371 | CLANG_CXX_LIBRARY = "libc++"; 372 | CLANG_ENABLE_MODULES = YES; 373 | CLANG_ENABLE_OBJC_ARC = YES; 374 | CLANG_WARN_BOOL_CONVERSION = YES; 375 | CLANG_WARN_CONSTANT_CONVERSION = YES; 376 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 377 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 378 | CLANG_WARN_EMPTY_BODY = YES; 379 | CLANG_WARN_ENUM_CONVERSION = YES; 380 | CLANG_WARN_INFINITE_RECURSION = YES; 381 | CLANG_WARN_INT_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 384 | CLANG_WARN_UNREACHABLE_CODE = YES; 385 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 386 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 387 | COPY_PHASE_STRIP = NO; 388 | DEBUG_INFORMATION_FORMAT = dwarf; 389 | ENABLE_STRICT_OBJC_MSGSEND = YES; 390 | ENABLE_TESTABILITY = YES; 391 | GCC_C_LANGUAGE_STANDARD = gnu99; 392 | GCC_DYNAMIC_NO_PIC = NO; 393 | GCC_NO_COMMON_BLOCKS = YES; 394 | GCC_OPTIMIZATION_LEVEL = 0; 395 | GCC_PREPROCESSOR_DEFINITIONS = ( 396 | "DEBUG=1", 397 | "$(inherited)", 398 | ); 399 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 400 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 401 | GCC_WARN_UNDECLARED_SELECTOR = YES; 402 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 403 | GCC_WARN_UNUSED_FUNCTION = YES; 404 | GCC_WARN_UNUSED_VARIABLE = YES; 405 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 406 | MTL_ENABLE_DEBUG_INFO = YES; 407 | ONLY_ACTIVE_ARCH = YES; 408 | SDKROOT = iphoneos; 409 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 410 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 411 | }; 412 | name = Debug; 413 | }; 414 | B93AE4F21F20AE10005084BD /* Release */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | ALWAYS_SEARCH_USER_PATHS = NO; 418 | CLANG_ANALYZER_NONNULL = YES; 419 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 420 | CLANG_CXX_LIBRARY = "libc++"; 421 | CLANG_ENABLE_MODULES = YES; 422 | CLANG_ENABLE_OBJC_ARC = YES; 423 | CLANG_WARN_BOOL_CONVERSION = YES; 424 | CLANG_WARN_CONSTANT_CONVERSION = YES; 425 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 426 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 427 | CLANG_WARN_EMPTY_BODY = YES; 428 | CLANG_WARN_ENUM_CONVERSION = YES; 429 | CLANG_WARN_INFINITE_RECURSION = YES; 430 | CLANG_WARN_INT_CONVERSION = YES; 431 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 432 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 433 | CLANG_WARN_UNREACHABLE_CODE = YES; 434 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 435 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 436 | COPY_PHASE_STRIP = NO; 437 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 438 | ENABLE_NS_ASSERTIONS = NO; 439 | ENABLE_STRICT_OBJC_MSGSEND = YES; 440 | GCC_C_LANGUAGE_STANDARD = gnu99; 441 | GCC_NO_COMMON_BLOCKS = YES; 442 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 443 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 444 | GCC_WARN_UNDECLARED_SELECTOR = YES; 445 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 446 | GCC_WARN_UNUSED_FUNCTION = YES; 447 | GCC_WARN_UNUSED_VARIABLE = YES; 448 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 449 | MTL_ENABLE_DEBUG_INFO = NO; 450 | SDKROOT = iphoneos; 451 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 452 | VALIDATE_PRODUCT = YES; 453 | }; 454 | name = Release; 455 | }; 456 | B93AE4F41F20AE10005084BD /* Debug */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 460 | CODE_SIGN_STYLE = Manual; 461 | DEVELOPMENT_TEAM = GH3WD8CYKW; 462 | INFOPLIST_FILE = SHFullscreenPopGestureSwiftDemo/Info.plist; 463 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 465 | PRODUCT_BUNDLE_IDENTIFIER = com.ShowHandAce.SHFullscreenPopGestureSwiftDemo; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | PROVISIONING_PROFILE = "c6f4f1bf-d71a-4cfe-b384-854992270a50"; 468 | PROVISIONING_PROFILE_SPECIFIER = "Wildcard Development"; 469 | SWIFT_VERSION = 4.0; 470 | }; 471 | name = Debug; 472 | }; 473 | B93AE4F51F20AE10005084BD /* Release */ = { 474 | isa = XCBuildConfiguration; 475 | buildSettings = { 476 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 477 | CODE_SIGN_STYLE = Manual; 478 | DEVELOPMENT_TEAM = ""; 479 | INFOPLIST_FILE = SHFullscreenPopGestureSwiftDemo/Info.plist; 480 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = com.ShowHandAce.SHFullscreenPopGestureSwiftDemo; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | PROVISIONING_PROFILE_SPECIFIER = ""; 485 | SWIFT_VERSION = 4.0; 486 | }; 487 | name = Release; 488 | }; 489 | B93AE4F71F20AE10005084BD /* Debug */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 493 | BUNDLE_LOADER = "$(TEST_HOST)"; 494 | INFOPLIST_FILE = SHFullscreenPopGestureSwiftDemoTests/Info.plist; 495 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 496 | PRODUCT_BUNDLE_IDENTIFIER = com.ShowHandAce.SHFullscreenPopGestureSwiftDemoTests; 497 | PRODUCT_NAME = "$(TARGET_NAME)"; 498 | SWIFT_VERSION = 3.0; 499 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SHFullscreenPopGestureSwiftDemo.app/SHFullscreenPopGestureSwiftDemo"; 500 | }; 501 | name = Debug; 502 | }; 503 | B93AE4F81F20AE10005084BD /* Release */ = { 504 | isa = XCBuildConfiguration; 505 | buildSettings = { 506 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 507 | BUNDLE_LOADER = "$(TEST_HOST)"; 508 | INFOPLIST_FILE = SHFullscreenPopGestureSwiftDemoTests/Info.plist; 509 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 510 | PRODUCT_BUNDLE_IDENTIFIER = com.ShowHandAce.SHFullscreenPopGestureSwiftDemoTests; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | SWIFT_VERSION = 3.0; 513 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SHFullscreenPopGestureSwiftDemo.app/SHFullscreenPopGestureSwiftDemo"; 514 | }; 515 | name = Release; 516 | }; 517 | B93AE4FA1F20AE10005084BD /* Debug */ = { 518 | isa = XCBuildConfiguration; 519 | buildSettings = { 520 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 521 | INFOPLIST_FILE = SHFullscreenPopGestureSwiftDemoUITests/Info.plist; 522 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 523 | PRODUCT_BUNDLE_IDENTIFIER = com.ShowHandAce.SHFullscreenPopGestureSwiftDemoUITests; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | SWIFT_VERSION = 3.0; 526 | TEST_TARGET_NAME = SHFullscreenPopGestureSwiftDemo; 527 | }; 528 | name = Debug; 529 | }; 530 | B93AE4FB1F20AE10005084BD /* Release */ = { 531 | isa = XCBuildConfiguration; 532 | buildSettings = { 533 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 534 | INFOPLIST_FILE = SHFullscreenPopGestureSwiftDemoUITests/Info.plist; 535 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 536 | PRODUCT_BUNDLE_IDENTIFIER = com.ShowHandAce.SHFullscreenPopGestureSwiftDemoUITests; 537 | PRODUCT_NAME = "$(TARGET_NAME)"; 538 | SWIFT_VERSION = 3.0; 539 | TEST_TARGET_NAME = SHFullscreenPopGestureSwiftDemo; 540 | }; 541 | name = Release; 542 | }; 543 | /* End XCBuildConfiguration section */ 544 | 545 | /* Begin XCConfigurationList section */ 546 | B93AE4C61F20AE0F005084BD /* Build configuration list for PBXProject "SHFullscreenPopGestureSwiftDemo" */ = { 547 | isa = XCConfigurationList; 548 | buildConfigurations = ( 549 | B93AE4F11F20AE10005084BD /* Debug */, 550 | B93AE4F21F20AE10005084BD /* Release */, 551 | ); 552 | defaultConfigurationIsVisible = 0; 553 | defaultConfigurationName = Release; 554 | }; 555 | B93AE4F31F20AE10005084BD /* Build configuration list for PBXNativeTarget "SHFullscreenPopGestureSwiftDemo" */ = { 556 | isa = XCConfigurationList; 557 | buildConfigurations = ( 558 | B93AE4F41F20AE10005084BD /* Debug */, 559 | B93AE4F51F20AE10005084BD /* Release */, 560 | ); 561 | defaultConfigurationIsVisible = 0; 562 | defaultConfigurationName = Release; 563 | }; 564 | B93AE4F61F20AE10005084BD /* Build configuration list for PBXNativeTarget "SHFullscreenPopGestureSwiftDemoTests" */ = { 565 | isa = XCConfigurationList; 566 | buildConfigurations = ( 567 | B93AE4F71F20AE10005084BD /* Debug */, 568 | B93AE4F81F20AE10005084BD /* Release */, 569 | ); 570 | defaultConfigurationIsVisible = 0; 571 | defaultConfigurationName = Release; 572 | }; 573 | B93AE4F91F20AE10005084BD /* Build configuration list for PBXNativeTarget "SHFullscreenPopGestureSwiftDemoUITests" */ = { 574 | isa = XCConfigurationList; 575 | buildConfigurations = ( 576 | B93AE4FA1F20AE10005084BD /* Debug */, 577 | B93AE4FB1F20AE10005084BD /* Release */, 578 | ); 579 | defaultConfigurationIsVisible = 0; 580 | defaultConfigurationName = Release; 581 | }; 582 | /* End XCConfigurationList section */ 583 | }; 584 | rootObject = B93AE4C31F20AE0F005084BD /* Project object */; 585 | } 586 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SHFullscreenPopGestureSwiftDemo 4 | // 5 | // Created by qjsios on 2017/7/20. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | // 启用 21 | SHFullscreenPopGesture.configure() 22 | 23 | return true 24 | } 25 | 26 | func applicationWillResignActive(_ application: UIApplication) { 27 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 28 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 29 | } 30 | 31 | func applicationDidEnterBackground(_ application: UIApplication) { 32 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | func applicationWillEnterForeground(_ application: UIApplication) { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | func applicationDidBecomeActive(_ application: UIApplication) { 41 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 42 | } 43 | 44 | func applicationWillTerminate(_ application: UIApplication) { 45 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 46 | } 47 | 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Assets.xcassets/ACE.imageset/ACE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ShowHandAce/SHFullscreenPopGestureSwift/e06dd0bf030b3eed2cc0edd2b2445afcd9f6f034/SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Assets.xcassets/ACE.imageset/ACE.png -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Assets.xcassets/ACE.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ACE.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHAceViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SHAceViewController.swift 3 | // SHFullscreenPopGestureSwiftDemo 4 | // 5 | // Created by qjsios on 2017/7/20. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SHAceViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Do any additional setup after loading the view. 17 | 18 | self.navigationItem.title = "ACE" 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | 26 | 27 | /* 28 | // MARK: - Navigation 29 | 30 | // In a storyboard-based application, you will often want to do a little preparation before navigation 31 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 32 | // Get the new view controller using segue.destinationViewController. 33 | // Pass the selected object to the new view controller. 34 | } 35 | */ 36 | 37 | } 38 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHAceViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHNoBarViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SHNoBarViewController.swift 3 | // SHFullscreenPopGestureSwiftDemo 4 | // 5 | // Created by qjsios on 2017/7/20. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SHNoBarViewController: UIViewController { 12 | 13 | required init?(coder aDecoder: NSCoder) { 14 | super.init(coder: aDecoder) 15 | } 16 | 17 | override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { 18 | super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 19 | 20 | } 21 | 22 | override func viewDidLoad() { 23 | super.viewDidLoad() 24 | 25 | // Do any additional setup after loading the view. 26 | 27 | self.sh_prefersNavigationBarHidden = true 28 | 29 | self.sh_interactivePopMaxAllowedInitialDistanceToLeftEdge = 200 30 | } 31 | 32 | @IBAction func pushButtonTouched(_ sender: UIButton) { 33 | 34 | self.navigationController?.pushViewController(SHAceViewController(), animated: true) 35 | } 36 | 37 | override func didReceiveMemoryWarning() { 38 | super.didReceiveMemoryWarning() 39 | // Dispose of any resources that can be recreated. 40 | } 41 | 42 | 43 | /* 44 | // MARK: - Navigation 45 | 46 | // In a storyboard-based application, you will often want to do a little preparation before navigation 47 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 48 | // Get the new view controller using segue.destinationViewController. 49 | // Pass the selected object to the new view controller. 50 | } 51 | */ 52 | 53 | } 54 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHNoBarViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 38 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHNoGestureViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SHNoGestureViewController.swift 3 | // SHFullscreenPopGestureSwiftDemo 4 | // 5 | // Created by qjsios on 2017/7/21. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SHNoGestureViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | 17 | // Do any additional setup after loading the view. 18 | 19 | self.navigationItem.title = "NoGesture" 20 | 21 | self.sh_interactivePopDisabled = true 22 | } 23 | 24 | @IBAction func pushButtonTouched(_ sender: UIButton) { 25 | 26 | self.navigationController?.pushViewController(SHAceViewController(), animated: true) 27 | } 28 | 29 | override func didReceiveMemoryWarning() { 30 | super.didReceiveMemoryWarning() 31 | // Dispose of any resources that can be recreated. 32 | } 33 | 34 | 35 | /* 36 | // MARK: - Navigation 37 | 38 | // In a storyboard-based application, you will often want to do a little preparation before navigation 39 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 40 | // Get the new view controller using segue.destinationViewController. 41 | // Pass the selected object to the new view controller. 42 | } 43 | */ 44 | 45 | } 46 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHNoGestureViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 33 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHScrollViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SHScrollViewController.swift 3 | // SHFullscreenPopGestureSwiftDemo 4 | // 5 | // Created by qjsios on 2017/7/21. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class SHScrollViewController: UIViewController { 12 | 13 | @IBOutlet weak var scrollView: UIScrollView! 14 | 15 | @IBOutlet weak var imgView: UIImageView! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | 22 | self.navigationItem.title = "Scroll" 23 | 24 | //设置 sh_scrollViewPopGestureRecognizerEnable 属性为 true 可以让 scrollView 的控制器具有左滑返回手势 25 | self.scrollView.sh_scrollViewPopGestureRecognizerEnable = true 26 | 27 | self.imgView.image = UIImage(named: "ACE")?.resizableImage(withCapInsets: .zero, resizingMode: .tile) 28 | } 29 | 30 | override func didReceiveMemoryWarning() { 31 | super.didReceiveMemoryWarning() 32 | // Dispose of any resources that can be recreated. 33 | } 34 | 35 | 36 | /* 37 | // MARK: - Navigation 38 | 39 | // In a storyboard-based application, you will often want to do a little preparation before navigation 40 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 41 | // Get the new view controller using segue.destinationViewController. 42 | // Pass the selected object to the new view controller. 43 | } 44 | */ 45 | 46 | } 47 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/SHScrollViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SHFullscreenPopGestureSwiftDemo 4 | // 5 | // Created by qjsios on 2017/7/20. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private let CellID = "cell" 12 | 13 | class ViewController: UITableViewController { 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | // Do any additional setup after loading the view, typically from a nib. 18 | 19 | self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: CellID) 20 | } 21 | 22 | // MARK: - UITableViewDataSource 23 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 24 | return 4 25 | } 26 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 27 | let cell = tableView.dequeueReusableCell(withIdentifier: CellID) 28 | cell?.textLabel?.text = dataSource[indexPath.row] 29 | cell?.textLabel?.font = UIFont.systemFont(ofSize: 14) 30 | cell?.accessoryType = .disclosureIndicator 31 | return cell! 32 | } 33 | 34 | // MARK: - UITableViewDelegate 35 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 36 | 37 | switch indexPath.row { 38 | case 0: 39 | self.navigationController?.pushViewController(SHAceViewController(), animated: true) 40 | case 1: 41 | self.navigationController?.pushViewController(SHNoBarViewController(), animated: true) 42 | case 2: 43 | self.navigationController?.pushViewController(SHScrollViewController(), animated: true) 44 | case 3: 45 | self.navigationController?.pushViewController(SHNoGestureViewController(), animated: true) 46 | default: break 47 | } 48 | } 49 | 50 | 51 | // MARK: - 数据 52 | private let dataSource = [ 53 | "0.Push a view controller with bar", 54 | "1.Push a view controller without bar", 55 | "2.Push a view controller with scrollView", 56 | "3.Push a view controller without pop gesture" 57 | ] 58 | 59 | // MARK: - 60 | override func didReceiveMemoryWarning() { 61 | super.didReceiveMemoryWarning() 62 | // Dispose of any resources that can be recreated. 63 | } 64 | 65 | 66 | } 67 | 68 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemoTests/SHFullscreenPopGestureSwiftDemoTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SHFullscreenPopGestureSwiftDemoTests.swift 3 | // SHFullscreenPopGestureSwiftDemoTests 4 | // 5 | // Created by qjsios on 2017/7/20. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import SHFullscreenPopGestureSwiftDemo 11 | 12 | class SHFullscreenPopGestureSwiftDemoTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SHFullscreenPopGestureSwiftDemo/SHFullscreenPopGestureSwiftDemoUITests/SHFullscreenPopGestureSwiftDemoUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SHFullscreenPopGestureSwiftDemoUITests.swift 3 | // SHFullscreenPopGestureSwiftDemoUITests 4 | // 5 | // Created by qjsios on 2017/7/20. 6 | // Copyright © 2017年 ShowHandAce. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class SHFullscreenPopGestureSwiftDemoUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------