├── .gitignore ├── PanPush.gif ├── PanPush ├── PanPush.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── PanPush │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── FirstViewController.h │ ├── FirstViewController.m │ ├── FirstViewController.xib │ ├── Info.plist │ ├── PanNavigationController │ ├── PanNavigationController.h │ ├── PanNavigationController.m │ └── PanSwiper │ │ ├── Animator │ │ ├── NSObject+TransitionContextHelper.h │ │ ├── NSObject+TransitionContextHelper.m │ │ ├── PanAnimator.h │ │ ├── PanAnimator.m │ │ ├── PanPopAnimator.h │ │ ├── PanPopAnimator.m │ │ ├── PanPushAnimator.h │ │ └── PanPushAnimator.m │ │ ├── PanSwiper.h │ │ ├── PanSwiper.m │ │ └── Transition │ │ ├── PanInteractiveTransition.h │ │ └── PanInteractiveTransition.m │ ├── PanPush.pch │ ├── SecondViewController.h │ ├── SecondViewController.m │ ├── SecondViewController.xib │ └── main.m └── README.md /.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 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /PanPush.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsbyfl/PanPush_NavigationController/7ed2455566a34b089854ad340dd78017d44a2f5c/PanPush.gif -------------------------------------------------------------------------------- /PanPush/PanPush.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 18B762471C99989200A93B7C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B762461C99989200A93B7C /* main.m */; }; 11 | 18B7624A1C99989200A93B7C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B762491C99989200A93B7C /* AppDelegate.m */; }; 12 | 18B762521C99989200A93B7C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18B762511C99989200A93B7C /* Assets.xcassets */; }; 13 | 18B7625F1C9998D000A93B7C /* FirstViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B7625D1C9998D000A93B7C /* FirstViewController.m */; }; 14 | 18B762601C9998D000A93B7C /* FirstViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 18B7625E1C9998D000A93B7C /* FirstViewController.xib */; }; 15 | 18B762641C9998DE00A93B7C /* SecondViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18B762621C9998DE00A93B7C /* SecondViewController.m */; }; 16 | 18B762651C9998DE00A93B7C /* SecondViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 18B762631C9998DE00A93B7C /* SecondViewController.xib */; }; 17 | E2661E5C1C9FEFA400DA57D8 /* PanNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2661E4C1C9FEFA400DA57D8 /* PanNavigationController.m */; }; 18 | E2661E5D1C9FEFA400DA57D8 /* NSObject+TransitionContextHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E2661E501C9FEFA400DA57D8 /* NSObject+TransitionContextHelper.m */; }; 19 | E2661E5E1C9FEFA400DA57D8 /* PanAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = E2661E521C9FEFA400DA57D8 /* PanAnimator.m */; }; 20 | E2661E5F1C9FEFA400DA57D8 /* PanPopAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = E2661E541C9FEFA400DA57D8 /* PanPopAnimator.m */; }; 21 | E2661E601C9FEFA400DA57D8 /* PanPushAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = E2661E561C9FEFA400DA57D8 /* PanPushAnimator.m */; }; 22 | E2661E611C9FEFA400DA57D8 /* PanSwiper.m in Sources */ = {isa = PBXBuildFile; fileRef = E2661E581C9FEFA400DA57D8 /* PanSwiper.m */; }; 23 | E2661E621C9FEFA400DA57D8 /* PanInteractiveTransition.m in Sources */ = {isa = PBXBuildFile; fileRef = E2661E5B1C9FEFA400DA57D8 /* PanInteractiveTransition.m */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 18B762421C99989200A93B7C /* PanPush.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PanPush.app; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 18B762461C99989200A93B7C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29 | 18B762481C99989200A93B7C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 30 | 18B762491C99989200A93B7C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 31 | 18B762511C99989200A93B7C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 32 | 18B762561C99989200A93B7C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 18B7625C1C9998D000A93B7C /* FirstViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FirstViewController.h; sourceTree = ""; }; 34 | 18B7625D1C9998D000A93B7C /* FirstViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FirstViewController.m; sourceTree = ""; }; 35 | 18B7625E1C9998D000A93B7C /* FirstViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = FirstViewController.xib; sourceTree = ""; }; 36 | 18B762611C9998DE00A93B7C /* SecondViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecondViewController.h; sourceTree = ""; }; 37 | 18B762621C9998DE00A93B7C /* SecondViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecondViewController.m; sourceTree = ""; }; 38 | 18B762631C9998DE00A93B7C /* SecondViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SecondViewController.xib; sourceTree = ""; }; 39 | 18B762661C999F4400A93B7C /* PanPush.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanPush.pch; sourceTree = ""; }; 40 | E2661E4B1C9FEFA400DA57D8 /* PanNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanNavigationController.h; sourceTree = ""; }; 41 | E2661E4C1C9FEFA400DA57D8 /* PanNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PanNavigationController.m; sourceTree = ""; }; 42 | E2661E4F1C9FEFA400DA57D8 /* NSObject+TransitionContextHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+TransitionContextHelper.h"; sourceTree = ""; }; 43 | E2661E501C9FEFA400DA57D8 /* NSObject+TransitionContextHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+TransitionContextHelper.m"; sourceTree = ""; }; 44 | E2661E511C9FEFA400DA57D8 /* PanAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanAnimator.h; sourceTree = ""; }; 45 | E2661E521C9FEFA400DA57D8 /* PanAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PanAnimator.m; sourceTree = ""; }; 46 | E2661E531C9FEFA400DA57D8 /* PanPopAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanPopAnimator.h; sourceTree = ""; }; 47 | E2661E541C9FEFA400DA57D8 /* PanPopAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PanPopAnimator.m; sourceTree = ""; }; 48 | E2661E551C9FEFA400DA57D8 /* PanPushAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanPushAnimator.h; sourceTree = ""; }; 49 | E2661E561C9FEFA400DA57D8 /* PanPushAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PanPushAnimator.m; sourceTree = ""; }; 50 | E2661E571C9FEFA400DA57D8 /* PanSwiper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanSwiper.h; sourceTree = ""; }; 51 | E2661E581C9FEFA400DA57D8 /* PanSwiper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PanSwiper.m; sourceTree = ""; }; 52 | E2661E5A1C9FEFA400DA57D8 /* PanInteractiveTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PanInteractiveTransition.h; sourceTree = ""; }; 53 | E2661E5B1C9FEFA400DA57D8 /* PanInteractiveTransition.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PanInteractiveTransition.m; sourceTree = ""; }; 54 | /* End PBXFileReference section */ 55 | 56 | /* Begin PBXFrameworksBuildPhase section */ 57 | 18B7623F1C99989200A93B7C /* Frameworks */ = { 58 | isa = PBXFrameworksBuildPhase; 59 | buildActionMask = 2147483647; 60 | files = ( 61 | ); 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | /* End PBXFrameworksBuildPhase section */ 65 | 66 | /* Begin PBXGroup section */ 67 | 18B762391C99989200A93B7C = { 68 | isa = PBXGroup; 69 | children = ( 70 | 18B762441C99989200A93B7C /* PanPush */, 71 | 18B762431C99989200A93B7C /* Products */, 72 | ); 73 | sourceTree = ""; 74 | }; 75 | 18B762431C99989200A93B7C /* Products */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 18B762421C99989200A93B7C /* PanPush.app */, 79 | ); 80 | name = Products; 81 | sourceTree = ""; 82 | }; 83 | 18B762441C99989200A93B7C /* PanPush */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | E2661E4A1C9FEFA400DA57D8 /* PanNavigationController */, 87 | 18B762481C99989200A93B7C /* AppDelegate.h */, 88 | 18B762491C99989200A93B7C /* AppDelegate.m */, 89 | 18B7625C1C9998D000A93B7C /* FirstViewController.h */, 90 | 18B7625D1C9998D000A93B7C /* FirstViewController.m */, 91 | 18B7625E1C9998D000A93B7C /* FirstViewController.xib */, 92 | 18B762611C9998DE00A93B7C /* SecondViewController.h */, 93 | 18B762621C9998DE00A93B7C /* SecondViewController.m */, 94 | 18B762631C9998DE00A93B7C /* SecondViewController.xib */, 95 | 18B762511C99989200A93B7C /* Assets.xcassets */, 96 | 18B762561C99989200A93B7C /* Info.plist */, 97 | 18B762451C99989200A93B7C /* Supporting Files */, 98 | ); 99 | path = PanPush; 100 | sourceTree = ""; 101 | }; 102 | 18B762451C99989200A93B7C /* Supporting Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 18B762461C99989200A93B7C /* main.m */, 106 | 18B762661C999F4400A93B7C /* PanPush.pch */, 107 | ); 108 | name = "Supporting Files"; 109 | sourceTree = ""; 110 | }; 111 | E2661E4A1C9FEFA400DA57D8 /* PanNavigationController */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | E2661E4B1C9FEFA400DA57D8 /* PanNavigationController.h */, 115 | E2661E4C1C9FEFA400DA57D8 /* PanNavigationController.m */, 116 | E2661E4D1C9FEFA400DA57D8 /* PanSwiper */, 117 | ); 118 | path = PanNavigationController; 119 | sourceTree = ""; 120 | }; 121 | E2661E4D1C9FEFA400DA57D8 /* PanSwiper */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | E2661E4E1C9FEFA400DA57D8 /* Animator */, 125 | E2661E571C9FEFA400DA57D8 /* PanSwiper.h */, 126 | E2661E581C9FEFA400DA57D8 /* PanSwiper.m */, 127 | E2661E591C9FEFA400DA57D8 /* Transition */, 128 | ); 129 | path = PanSwiper; 130 | sourceTree = ""; 131 | }; 132 | E2661E4E1C9FEFA400DA57D8 /* Animator */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | E2661E4F1C9FEFA400DA57D8 /* NSObject+TransitionContextHelper.h */, 136 | E2661E501C9FEFA400DA57D8 /* NSObject+TransitionContextHelper.m */, 137 | E2661E511C9FEFA400DA57D8 /* PanAnimator.h */, 138 | E2661E521C9FEFA400DA57D8 /* PanAnimator.m */, 139 | E2661E531C9FEFA400DA57D8 /* PanPopAnimator.h */, 140 | E2661E541C9FEFA400DA57D8 /* PanPopAnimator.m */, 141 | E2661E551C9FEFA400DA57D8 /* PanPushAnimator.h */, 142 | E2661E561C9FEFA400DA57D8 /* PanPushAnimator.m */, 143 | ); 144 | path = Animator; 145 | sourceTree = ""; 146 | }; 147 | E2661E591C9FEFA400DA57D8 /* Transition */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | E2661E5A1C9FEFA400DA57D8 /* PanInteractiveTransition.h */, 151 | E2661E5B1C9FEFA400DA57D8 /* PanInteractiveTransition.m */, 152 | ); 153 | path = Transition; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXNativeTarget section */ 159 | 18B762411C99989200A93B7C /* PanPush */ = { 160 | isa = PBXNativeTarget; 161 | buildConfigurationList = 18B762591C99989200A93B7C /* Build configuration list for PBXNativeTarget "PanPush" */; 162 | buildPhases = ( 163 | 18B7623E1C99989200A93B7C /* Sources */, 164 | 18B7623F1C99989200A93B7C /* Frameworks */, 165 | 18B762401C99989200A93B7C /* Resources */, 166 | ); 167 | buildRules = ( 168 | ); 169 | dependencies = ( 170 | ); 171 | name = PanPush; 172 | productName = PanPush; 173 | productReference = 18B762421C99989200A93B7C /* PanPush.app */; 174 | productType = "com.apple.product-type.application"; 175 | }; 176 | /* End PBXNativeTarget section */ 177 | 178 | /* Begin PBXProject section */ 179 | 18B7623A1C99989200A93B7C /* Project object */ = { 180 | isa = PBXProject; 181 | attributes = { 182 | LastUpgradeCheck = 0720; 183 | ORGANIZATIONNAME = lpc; 184 | TargetAttributes = { 185 | 18B762411C99989200A93B7C = { 186 | CreatedOnToolsVersion = 7.2; 187 | }; 188 | }; 189 | }; 190 | buildConfigurationList = 18B7623D1C99989200A93B7C /* Build configuration list for PBXProject "PanPush" */; 191 | compatibilityVersion = "Xcode 3.2"; 192 | developmentRegion = English; 193 | hasScannedForEncodings = 0; 194 | knownRegions = ( 195 | en, 196 | Base, 197 | ); 198 | mainGroup = 18B762391C99989200A93B7C; 199 | productRefGroup = 18B762431C99989200A93B7C /* Products */; 200 | projectDirPath = ""; 201 | projectRoot = ""; 202 | targets = ( 203 | 18B762411C99989200A93B7C /* PanPush */, 204 | ); 205 | }; 206 | /* End PBXProject section */ 207 | 208 | /* Begin PBXResourcesBuildPhase section */ 209 | 18B762401C99989200A93B7C /* Resources */ = { 210 | isa = PBXResourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | 18B762521C99989200A93B7C /* Assets.xcassets in Resources */, 214 | 18B762601C9998D000A93B7C /* FirstViewController.xib in Resources */, 215 | 18B762651C9998DE00A93B7C /* SecondViewController.xib in Resources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXSourcesBuildPhase section */ 222 | 18B7623E1C99989200A93B7C /* Sources */ = { 223 | isa = PBXSourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | 18B762641C9998DE00A93B7C /* SecondViewController.m in Sources */, 227 | E2661E611C9FEFA400DA57D8 /* PanSwiper.m in Sources */, 228 | E2661E5C1C9FEFA400DA57D8 /* PanNavigationController.m in Sources */, 229 | 18B7624A1C99989200A93B7C /* AppDelegate.m in Sources */, 230 | 18B7625F1C9998D000A93B7C /* FirstViewController.m in Sources */, 231 | E2661E5F1C9FEFA400DA57D8 /* PanPopAnimator.m in Sources */, 232 | E2661E5D1C9FEFA400DA57D8 /* NSObject+TransitionContextHelper.m in Sources */, 233 | 18B762471C99989200A93B7C /* main.m in Sources */, 234 | E2661E5E1C9FEFA400DA57D8 /* PanAnimator.m in Sources */, 235 | E2661E601C9FEFA400DA57D8 /* PanPushAnimator.m in Sources */, 236 | E2661E621C9FEFA400DA57D8 /* PanInteractiveTransition.m in Sources */, 237 | ); 238 | runOnlyForDeploymentPostprocessing = 0; 239 | }; 240 | /* End PBXSourcesBuildPhase section */ 241 | 242 | /* Begin XCBuildConfiguration section */ 243 | 18B762571C99989200A93B7C /* Debug */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_MODULES = YES; 250 | CLANG_ENABLE_OBJC_ARC = YES; 251 | CLANG_WARN_BOOL_CONVERSION = YES; 252 | CLANG_WARN_CONSTANT_CONVERSION = YES; 253 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 254 | CLANG_WARN_EMPTY_BODY = YES; 255 | CLANG_WARN_ENUM_CONVERSION = YES; 256 | CLANG_WARN_INT_CONVERSION = YES; 257 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 258 | CLANG_WARN_UNREACHABLE_CODE = YES; 259 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 260 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 261 | COPY_PHASE_STRIP = NO; 262 | DEBUG_INFORMATION_FORMAT = dwarf; 263 | ENABLE_STRICT_OBJC_MSGSEND = YES; 264 | ENABLE_TESTABILITY = YES; 265 | GCC_C_LANGUAGE_STANDARD = gnu99; 266 | GCC_DYNAMIC_NO_PIC = NO; 267 | GCC_NO_COMMON_BLOCKS = YES; 268 | GCC_OPTIMIZATION_LEVEL = 0; 269 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 270 | GCC_PREFIX_HEADER = "$(SRCROOT)/PanPush/PanPush.pch"; 271 | GCC_PREPROCESSOR_DEFINITIONS = ( 272 | "DEBUG=1", 273 | "$(inherited)", 274 | ); 275 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 276 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 277 | GCC_WARN_UNDECLARED_SELECTOR = YES; 278 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 279 | GCC_WARN_UNUSED_FUNCTION = YES; 280 | GCC_WARN_UNUSED_VARIABLE = YES; 281 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 282 | MTL_ENABLE_DEBUG_INFO = YES; 283 | ONLY_ACTIVE_ARCH = YES; 284 | SDKROOT = iphoneos; 285 | }; 286 | name = Debug; 287 | }; 288 | 18B762581C99989200A93B7C /* Release */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | ALWAYS_SEARCH_USER_PATHS = NO; 292 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 293 | CLANG_CXX_LIBRARY = "libc++"; 294 | CLANG_ENABLE_MODULES = YES; 295 | CLANG_ENABLE_OBJC_ARC = YES; 296 | CLANG_WARN_BOOL_CONVERSION = YES; 297 | CLANG_WARN_CONSTANT_CONVERSION = YES; 298 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 299 | CLANG_WARN_EMPTY_BODY = YES; 300 | CLANG_WARN_ENUM_CONVERSION = YES; 301 | CLANG_WARN_INT_CONVERSION = YES; 302 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 303 | CLANG_WARN_UNREACHABLE_CODE = YES; 304 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 305 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 306 | COPY_PHASE_STRIP = NO; 307 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 308 | ENABLE_NS_ASSERTIONS = NO; 309 | ENABLE_STRICT_OBJC_MSGSEND = YES; 310 | GCC_C_LANGUAGE_STANDARD = gnu99; 311 | GCC_NO_COMMON_BLOCKS = YES; 312 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 313 | GCC_PREFIX_HEADER = "$(SRCROOT)/PanPush/PanPush.pch"; 314 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 315 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 316 | GCC_WARN_UNDECLARED_SELECTOR = YES; 317 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 318 | GCC_WARN_UNUSED_FUNCTION = YES; 319 | GCC_WARN_UNUSED_VARIABLE = YES; 320 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 321 | MTL_ENABLE_DEBUG_INFO = NO; 322 | SDKROOT = iphoneos; 323 | VALIDATE_PRODUCT = YES; 324 | }; 325 | name = Release; 326 | }; 327 | 18B7625A1C99989200A93B7C /* Debug */ = { 328 | isa = XCBuildConfiguration; 329 | buildSettings = { 330 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 331 | INFOPLIST_FILE = PanPush/Info.plist; 332 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 333 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 334 | PRODUCT_BUNDLE_IDENTIFIER = com.test.PanPush; 335 | PRODUCT_NAME = "$(TARGET_NAME)"; 336 | }; 337 | name = Debug; 338 | }; 339 | 18B7625B1C99989200A93B7C /* Release */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 343 | INFOPLIST_FILE = PanPush/Info.plist; 344 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 345 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 346 | PRODUCT_BUNDLE_IDENTIFIER = com.test.PanPush; 347 | PRODUCT_NAME = "$(TARGET_NAME)"; 348 | }; 349 | name = Release; 350 | }; 351 | /* End XCBuildConfiguration section */ 352 | 353 | /* Begin XCConfigurationList section */ 354 | 18B7623D1C99989200A93B7C /* Build configuration list for PBXProject "PanPush" */ = { 355 | isa = XCConfigurationList; 356 | buildConfigurations = ( 357 | 18B762571C99989200A93B7C /* Debug */, 358 | 18B762581C99989200A93B7C /* Release */, 359 | ); 360 | defaultConfigurationIsVisible = 0; 361 | defaultConfigurationName = Release; 362 | }; 363 | 18B762591C99989200A93B7C /* Build configuration list for PBXNativeTarget "PanPush" */ = { 364 | isa = XCConfigurationList; 365 | buildConfigurations = ( 366 | 18B7625A1C99989200A93B7C /* Debug */, 367 | 18B7625B1C99989200A93B7C /* Release */, 368 | ); 369 | defaultConfigurationIsVisible = 0; 370 | defaultConfigurationName = Release; 371 | }; 372 | /* End XCConfigurationList section */ 373 | }; 374 | rootObject = 18B7623A1C99989200A93B7C /* Project object */; 375 | } 376 | -------------------------------------------------------------------------------- /PanPush/PanPush.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PanPush/PanPush/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /PanPush/PanPush/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "PanNavigationController.h" 11 | 12 | @interface AppDelegate () 13 | @property (nonatomic,strong) UITabBarController *rootTabbarController; 14 | @end 15 | 16 | @implementation AppDelegate 17 | 18 | 19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 20 | 21 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 22 | 23 | #if 1 24 | FirstViewController *rootNavController = [[FirstViewController alloc] initWithNibName:NSStringFromClass([FirstViewController class]) bundle:nil]; 25 | PanNavigationController *nav = [[PanNavigationController alloc] initWithRootViewController:rootNavController]; 26 | self.window.rootViewController = nav; 27 | #else 28 | self.rootTabbarController = [self customTabbar]; 29 | self.window.rootViewController = self.rootTabbarController; 30 | 31 | #endif 32 | 33 | self.window.backgroundColor = [UIColor whiteColor]; 34 | [self.window makeKeyAndVisible]; 35 | return YES; 36 | } 37 | 38 | - (UITabBarController *)customTabbar 39 | { 40 | FirstViewController *vc1 = [[FirstViewController alloc] initWithNibName:NSStringFromClass([FirstViewController class]) bundle:nil]; 41 | PanNavigationController *nav1 = [[PanNavigationController alloc] initWithRootViewController:vc1]; 42 | 43 | SecondViewController *vc2 = [[SecondViewController alloc] initWithNibName:NSStringFromClass([SecondViewController class]) bundle:nil]; 44 | PanNavigationController *nav2 = [[PanNavigationController alloc] initWithRootViewController:vc2]; 45 | 46 | FirstViewController *vc3 = [[FirstViewController alloc] initWithNibName:NSStringFromClass([FirstViewController class]) bundle:nil]; 47 | PanNavigationController *nav3 = [[PanNavigationController alloc] initWithRootViewController:vc3]; 48 | 49 | 50 | UITabBarController *tabbarController = [[UITabBarController alloc] init]; 51 | tabbarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3, nil]; 52 | NSArray *items = tabbarController.tabBar.items; 53 | for (int i = 0;i < items.count;i++) { 54 | UITabBarItem *item = items[i]; 55 | item.title = [NSString stringWithFormat:@"第 %@ 个",@(i)]; 56 | } 57 | 58 | return tabbarController; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /PanPush/PanPush/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /PanPush/PanPush/FirstViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // FirstViewController.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FirstViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PanPush/PanPush/FirstViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // FirstViewController.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "FirstViewController.h" 10 | 11 | @interface FirstViewController () 12 | @property (weak, nonatomic) IBOutlet UILabel *label; 13 | 14 | @end 15 | 16 | @implementation FirstViewController 17 | 18 | - (void)viewDidAppear:(BOOL)animated 19 | { 20 | [super viewDidAppear:animated]; 21 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 22 | [nav setNextViewControllerDelegate:self]; 23 | } 24 | 25 | - (void)viewWillDisappear:(BOOL)animated 26 | { 27 | [super viewWillDisappear:animated]; 28 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 29 | [nav setNextViewControllerDelegate:nil]; 30 | } 31 | 32 | - (void)viewDidLoad { 33 | [super viewDidLoad]; 34 | 35 | NSInteger count = self.navigationController.viewControllers.count; 36 | NSString *name = NSStringFromClass([self class]); 37 | self.label.text = [NSString stringWithFormat:@"第 %@ 个\n%@",@(count),name]; 38 | } 39 | 40 | 41 | #pragma mark -- Button Response -- 42 | - (IBAction)push:(id)sender { 43 | SecondViewController *controller = [[SecondViewController alloc] initWithNibName:NSStringFromClass([SecondViewController class]) bundle:nil]; 44 | [self.navigationController pushViewController:controller animated:YES]; 45 | } 46 | 47 | - (IBAction)popToRoot:(id)sender { 48 | NSInteger count = self.navigationController.viewControllers.count; 49 | if (count > 1) { 50 | [self.navigationController popToRootViewControllerAnimated:YES]; 51 | } 52 | } 53 | 54 | 55 | #pragma mark -- PanSwiper Delegate -- 56 | - (UIViewController *)swiperBeginPanPushToNextController:(PanSwiper *)swiper 57 | { 58 | SecondViewController *controller = [[SecondViewController alloc] initWithNibName:NSStringFromClass([SecondViewController class]) bundle:nil]; 59 | controller.hidesBottomBarWhenPushed = YES; 60 | return controller; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /PanPush/PanPush/FirstViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 41 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /PanPush/PanPush/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PanNavigationController.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | // 代码地址:https://github.com/jsbyfl/PanPush_NavigationController.git 9 | 10 | #import 11 | #import "PanSwiper.h" 12 | 13 | @interface PanNavigationController : UINavigationController 14 | 15 | /** 16 | * 是否禁止右滑返回(Defualt is NO) 17 | */ 18 | @property (nonatomic,assign) BOOL isForbidDragBack; 19 | 20 | /** 21 | * 设置左滑push页面的代理 22 | * 23 | * @param panPushDelegate 左滑push页面的代理 24 | */ 25 | - (void)setNextViewControllerDelegate:(id )panPushDelegate; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PanNavigationController.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanNavigationController.h" 10 | 11 | @interface PanNavigationController () 12 | 13 | @property (nonatomic,readwrite,strong) PanSwiper *swiper; 14 | 15 | @end 16 | 17 | @implementation PanNavigationController 18 | 19 | -(void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | self.swiper = [[PanSwiper alloc] initWithNavigationController:self]; 23 | } 24 | 25 | 26 | #pragma mark -- Setters and getters -- 27 | 28 | - (void)setIsForbidDragBack:(BOOL)isForbidDragBack{ 29 | self.swiper.isForbidDragBack = isForbidDragBack; 30 | } 31 | 32 | - (BOOL)isForbidDragBack{ 33 | return self.swiper.isForbidDragBack; 34 | } 35 | 36 | - (void)setNextViewControllerDelegate:(id)panPushDelegate{ 37 | self.swiper.panPushDelegate = panPushDelegate; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/NSObject+TransitionContextHelper.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+TransitionContextHelper.h 3 | // PanPush 4 | // 5 | // Created by Paddy-long on 16/3/18. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface NSObject (TransitionContextHelper) 13 | 14 | - (UIView *)transition_toView; 15 | - (UIView *)transition_fromView; 16 | 17 | - (UIViewController *)transition_toViewController; 18 | - (UIViewController *)transition_fromViewController; 19 | 20 | @end 21 | 22 | 23 | @interface UIView (TransitionShadow) 24 | 25 | - (void)addLeftSideShadowWithFading; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/NSObject+TransitionContextHelper.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject+TransitionContextHelper.m 3 | // PanPush 4 | // 5 | // Created by Paddy-long on 16/3/18. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "NSObject+TransitionContextHelper.h" 10 | 11 | @implementation NSObject (TransitionContextHelper) 12 | 13 | #pragma mark -- UIView -- 14 | - (UIView *)transition_toView 15 | { 16 | return [self _TransitionViewHelper:YES]; 17 | } 18 | - (UIView *)transition_fromView 19 | { 20 | return [self _TransitionViewHelper:NO]; 21 | } 22 | 23 | - (UIView *)_TransitionViewHelper:(BOOL)isToView 24 | { 25 | NSAssert([self conformsToProtocol:@protocol(UIViewControllerContextTransitioning)], @"bad parameter"); 26 | if (![self conformsToProtocol:@protocol(UIViewControllerContextTransitioning)]) { 27 | return nil; 28 | } 29 | id context = (id)self; 30 | 31 | NSString *controllerKey = isToView ? UITransitionContextToViewControllerKey : UITransitionContextFromViewControllerKey; 32 | 33 | UIViewController *controller = [context viewControllerForKey:controllerKey]; 34 | 35 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 36 | if ([context respondsToSelector:@selector(viewForKey:)]) { 37 | NSString *viewKey = isToView ? UITransitionContextToViewKey : UITransitionContextFromViewKey; 38 | return [context viewForKey:viewKey]; 39 | } 40 | else { 41 | return controller.view; 42 | } 43 | #else 44 | return controller.view; 45 | #endif 46 | } 47 | 48 | 49 | #pragma mark -- Controller -- 50 | - (UIViewController *)transition_toViewController 51 | { 52 | return [self _TransitionControllerHelper:YES]; 53 | } 54 | - (UIViewController *)transition_fromViewController 55 | { 56 | return [self _TransitionControllerHelper:NO]; 57 | } 58 | 59 | - (UIViewController *)_TransitionControllerHelper:(BOOL)isToView 60 | { 61 | NSAssert([self conformsToProtocol:@protocol(UIViewControllerContextTransitioning)], @"bad parameter"); 62 | if (![self conformsToProtocol:@protocol(UIViewControllerContextTransitioning)]) { 63 | return nil; 64 | } 65 | id context = (id)self; 66 | 67 | NSString *controllerKey = isToView ? UITransitionContextToViewControllerKey : UITransitionContextFromViewControllerKey; 68 | 69 | return [context viewControllerForKey:controllerKey]; 70 | } 71 | 72 | @end 73 | 74 | 75 | 76 | #pragma mark -- TransitionShadow -- 77 | @implementation UIView (TransitionShadow) 78 | - (void)addLeftSideShadowWithFading 79 | { 80 | CGFloat shadowWidth = 4.0f; 81 | CGFloat shadowVerticalPadding = -1.0f; 82 | CGFloat shadowHeight = CGRectGetHeight(self.frame) - 2 * shadowVerticalPadding; 83 | CGRect shadowRect = CGRectMake(-shadowWidth, shadowVerticalPadding, shadowWidth, shadowHeight); 84 | UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:shadowRect]; 85 | self.layer.shadowPath = [shadowPath CGPath]; 86 | self.layer.shadowOpacity = 0.2f; 87 | 88 | 89 | CGFloat toValue = 0.1f; 90 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"]; 91 | animation.fromValue = @(self.layer.shadowOpacity); 92 | animation.toValue = @(toValue); 93 | [self.layer addAnimation:animation forKey:nil]; 94 | self.layer.shadowOpacity = toValue; 95 | } 96 | @end 97 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/PanAnimator.h: -------------------------------------------------------------------------------- 1 | // 2 | // PanAnimator.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "NSObject+TransitionContextHelper.h" 11 | @protocol PanAnimatorDelegate; 12 | 13 | @interface PanAnimator : NSObject 14 | @property (nonatomic,weak) id delegate; 15 | @end 16 | 17 | 18 | @protocol PanAnimatorDelegate 19 | @required 20 | /** 21 | * 动画结束时的回调,必须实现. 22 | */ 23 | - (void)animator:(PanAnimator *)animator completeWithTransitionFinished:(BOOL)finish; 24 | 25 | @end -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/PanAnimator.m: -------------------------------------------------------------------------------- 1 | // 2 | // PanAnimator.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanAnimator.h" 10 | 11 | @implementation PanAnimator 12 | 13 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext 14 | { 15 | return 0.35; 16 | } 17 | 18 | - (void)animateTransition:(id )transitionContext 19 | { 20 | [NSException raise:NSInternalInconsistencyException format:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)]; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/PanPopAnimator.h: -------------------------------------------------------------------------------- 1 | // 2 | // PanAnimator.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanAnimator.h" 10 | 11 | @interface PanPopAnimator : PanAnimator 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/PanPopAnimator.m: -------------------------------------------------------------------------------- 1 | // 2 | // PanAnimator.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanPopAnimator.h" 10 | 11 | @implementation PanPopAnimator 12 | @synthesize delegate = _delegate; 13 | 14 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext 15 | { 16 | return 0.5; 17 | } 18 | 19 | - (void)animateTransition:(id )transitionContext 20 | { 21 | //上一个controller 22 | UIViewController *previousController = [(NSObject *)transitionContext transition_toViewController]; 23 | //当前controller 24 | UIViewController *currentController = [(NSObject *)transitionContext transition_fromViewController]; 25 | UIView *_containerView = [transitionContext containerView]; 26 | [_containerView insertSubview:previousController.view belowSubview:currentController.view]; 27 | 28 | //设置动画开始时,上一个controller的偏移量 29 | CGFloat previousControllerXTranslation = - CGRectGetWidth(_containerView.bounds) * 0.3f; 30 | previousController.view.transform = CGAffineTransformMakeTranslation(previousControllerXTranslation, 0); 31 | 32 | //设置左侧阴影 33 | [currentController.view addLeftSideShadowWithFading]; 34 | 35 | //黑色蒙层 36 | UIView *dimmingView = [[UIView alloc] initWithFrame:previousController.view.bounds]; 37 | dimmingView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.2f]; 38 | [previousController.view addSubview:dimmingView]; 39 | 40 | BOOL previousClipsToBounds = currentController.view.clipsToBounds; 41 | currentController.view.clipsToBounds = NO; 42 | 43 | 44 | //TabbarController hidesBottomBarWhenPushed 45 | UITabBarController *tabBarController = previousController.tabBarController; 46 | UINavigationController *navController = previousController.navigationController; 47 | UITabBar *tempTabbar = tabBarController.tabBar; 48 | BOOL shouldAddTabBarBackToTabBarController = NO; 49 | BOOL hidesBottomBarWhenPushed = currentController.hidesBottomBarWhenPushed; 50 | BOOL tabBarControllerContainsToViewController = [tabBarController.viewControllers containsObject:previousController]; 51 | BOOL tabBarControllerContainsNavController = [tabBarController.viewControllers containsObject:navController]; 52 | BOOL isToViewControllerFirstInNavController = [navController.viewControllers firstObject] == previousController; 53 | 54 | if (hidesBottomBarWhenPushed && tempTabbar && (tabBarControllerContainsToViewController || (isToViewControllerFirstInNavController && tabBarControllerContainsNavController))) { 55 | [previousController.view addSubview:tempTabbar]; 56 | shouldAddTabBarBackToTabBarController = YES; 57 | CGFloat transform_tabbar = (previousController.view.frame.size.width); 58 | tempTabbar.transform = CGAffineTransformMakeTranslation(transform_tabbar, 0); 59 | 60 | BOOL _navTranslucent = navController.navigationBar.translucent; 61 | BOOL _tabbarTranslucent = tempTabbar.translucent; 62 | if (!navController.navigationBarHidden) { 63 | if (_navTranslucent == YES && _tabbarTranslucent == YES) { 64 | 65 | } 66 | else if (_navTranslucent == NO && _tabbarTranslucent == YES) { 67 | CGRect oldFrame = tempTabbar.frame; 68 | oldFrame.origin.y = CGRectGetHeight(tabBarController.view.frame) - CGRectGetHeight(oldFrame) - CGRectGetMaxY(navController.navigationBar.frame); 69 | tempTabbar.frame = oldFrame; 70 | } 71 | else if (_navTranslucent == YES && _tabbarTranslucent == NO) { 72 | //NEED TO DO 73 | 74 | } 75 | else if (_navTranslucent == NO && _tabbarTranslucent == NO) { 76 | //NEED TO DO 77 | 78 | } 79 | } 80 | } 81 | 82 | [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ 83 | if (shouldAddTabBarBackToTabBarController) { 84 | tempTabbar.transform = CGAffineTransformIdentity; 85 | } 86 | 87 | //设置动画结束时,2个Controller的偏移量 (目标controller必须重置) 88 | previousController.view.transform = CGAffineTransformIdentity; 89 | CGFloat transform_tx = previousController.view.frame.size.width; 90 | currentController.view.transform = CGAffineTransformMakeTranslation(transform_tx, 0); 91 | dimmingView.alpha = 0.0f; 92 | 93 | } completion:^(BOOL finished) { 94 | if (shouldAddTabBarBackToTabBarController) { 95 | CGRect oldFrame = tempTabbar.frame; 96 | oldFrame.origin.y = CGRectGetHeight(tabBarController.view.frame) - CGRectGetHeight(oldFrame); 97 | tempTabbar.frame = oldFrame; 98 | [tabBarController.view addSubview:tempTabbar]; 99 | tempTabbar.transform = CGAffineTransformIdentity; 100 | } 101 | [dimmingView removeFromSuperview]; 102 | 103 | //重置上一个controller的偏移量(当前的controller不在栈里) 104 | previousController.view.transform = CGAffineTransformIdentity; 105 | previousController.view.clipsToBounds = previousClipsToBounds; 106 | 107 | BOOL didComplete = ![transitionContext transitionWasCancelled]; 108 | [transitionContext completeTransition:didComplete]; 109 | [self.delegate animator:self completeWithTransitionFinished:didComplete]; 110 | }]; 111 | } 112 | 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/PanPushAnimator.h: -------------------------------------------------------------------------------- 1 | // 2 | // PanPushAnimator.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanAnimator.h" 10 | 11 | @interface PanPushAnimator : PanAnimator 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Animator/PanPushAnimator.m: -------------------------------------------------------------------------------- 1 | // 2 | // PanPushAnimator.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanPushAnimator.h" 10 | 11 | @implementation PanPushAnimator 12 | @synthesize delegate = _delegate; 13 | 14 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext 15 | { 16 | return 0.5; 17 | } 18 | 19 | - (void)animateTransition:(id )transitionContext 20 | { 21 | //下一个controller 22 | UIViewController *nextController = [(NSObject *)transitionContext transition_toViewController]; 23 | //当前controller 24 | UIViewController *currentController = [(NSObject *)transitionContext transition_fromViewController]; 25 | UIView *_containerView = [transitionContext containerView]; 26 | [_containerView insertSubview:nextController.view aboveSubview:currentController.view]; 27 | 28 | //设置下一个Controller的frame 29 | nextController.view.frame = [transitionContext finalFrameForViewController:nextController]; 30 | 31 | //设置动画开始时,nextController的偏移量 32 | CGFloat nextControllerXTranslation = CGRectGetWidth(_containerView.bounds); 33 | nextController.view.transform = CGAffineTransformMakeTranslation(nextControllerXTranslation, 0); 34 | 35 | //设置左侧阴影 36 | [nextController.view addLeftSideShadowWithFading]; 37 | 38 | //黑色蒙层 39 | UIView *dimmingView = [[UIView alloc] initWithFrame:currentController.view.bounds]; 40 | dimmingView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.2f]; 41 | dimmingView.alpha = 0.0f; 42 | [currentController.view addSubview:dimmingView]; 43 | 44 | BOOL nextClipsToBounds = currentController.view.clipsToBounds; 45 | nextController.view.clipsToBounds = NO; 46 | 47 | 48 | //TabbarController hidesBottomBarWhenPushed 49 | UITabBarController *tabBarController = currentController.tabBarController; 50 | UINavigationController *navController = currentController.navigationController; 51 | UITabBar *tabBar = tabBarController.tabBar; 52 | BOOL shouldAddTabBarBackToTabBarController = NO; 53 | BOOL hidesBottomBarWhenPushed = nextController.hidesBottomBarWhenPushed; 54 | BOOL tabBarControllerContainsToViewController = [tabBarController.viewControllers containsObject:currentController]; 55 | BOOL tabBarControllerContainsNavController = [tabBarController.viewControllers containsObject:navController]; 56 | BOOL isToViewControllerFirstInNavController = [navController.viewControllers firstObject] == currentController; 57 | if (hidesBottomBarWhenPushed && tabBar && (tabBarControllerContainsToViewController || (isToViewControllerFirstInNavController && tabBarControllerContainsNavController))) { 58 | [currentController.view addSubview:tabBar]; 59 | shouldAddTabBarBackToTabBarController = YES; 60 | tabBar.transform = CGAffineTransformIdentity; 61 | } 62 | 63 | 64 | [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ 65 | if (shouldAddTabBarBackToTabBarController) { 66 | CGFloat transform_tabbar = (currentController.view.frame.size.width); 67 | tabBar.transform = CGAffineTransformMakeTranslation(transform_tabbar, 0); 68 | } 69 | 70 | //设置动画结束时,2个Controller的偏移量 (目标controller必须重置) 71 | nextController.view.transform = CGAffineTransformIdentity; 72 | CGFloat transform_tx = - (currentController.view.frame.size.width) * 0.4; 73 | currentController.view.transform = CGAffineTransformMakeTranslation(transform_tx, 0); 74 | 75 | dimmingView.alpha = 1.0f; 76 | 77 | } completion:^(BOOL finished) { 78 | if (shouldAddTabBarBackToTabBarController) { 79 | [tabBarController.view addSubview:tabBar]; 80 | tabBar.transform = CGAffineTransformIdentity; 81 | } 82 | 83 | [dimmingView removeFromSuperview]; 84 | //重置2个Controller的偏移量(2个controller都在栈里) 85 | currentController.view.transform = CGAffineTransformIdentity; 86 | nextController.view.transform = CGAffineTransformIdentity; 87 | nextController.view.clipsToBounds = nextClipsToBounds; 88 | 89 | BOOL didComplete = ![transitionContext transitionWasCancelled]; 90 | [transitionContext completeTransition:didComplete]; 91 | [self.delegate animator:self completeWithTransitionFinished:didComplete]; 92 | }]; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/PanSwiper.h: -------------------------------------------------------------------------------- 1 | // 2 | // PanSwiper.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | // 代码地址:https://github.com/jsbyfl/PanPush_NavigationController.git 9 | 10 | #import 11 | @protocol PanPushToNextViewControllerDelegate; 12 | 13 | #define k_Progress_Pan_Pop 0.4 //Pop触发的滑动比例 14 | #define k_Progress_Pan_Push 0.3 //Push触发的滑动比例 15 | 16 | @interface PanSwiper : NSObject 17 | 18 | @property (nonatomic,assign) BOOL isForbidDragBack; //Defalt is NO. 19 | @property (nonatomic,weak) id panPushDelegate; 20 | 21 | - (instancetype)initWithNavigationController:(UINavigationController *)navigationController; 22 | 23 | @end 24 | 25 | 26 | @protocol PanPushToNextViewControllerDelegate 27 | 28 | @optional 29 | - (UIViewController *)swiperBeginPanPushToNextController:(PanSwiper *)swiper; 30 | - (void)swiperDidEndPanPushToNextController:(PanSwiper *)swiper; 31 | 32 | @end -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/PanSwiper.m: -------------------------------------------------------------------------------- 1 | // 2 | // PanSwiper.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanSwiper.h" 10 | #import "PanPopAnimator.h" 11 | #import "PanPushAnimator.h" 12 | #import "PanInteractiveTransition.h" 13 | 14 | typedef NS_ENUM(NSInteger, PanGestureRecognizer_Direction) { 15 | PanGestureRecognizer_Direction_None = 0, 16 | PanGestureRecognizer_Direction_Left = 1, 17 | PanGestureRecognizer_Direction_Right = 2, 18 | }; 19 | 20 | @interface PanSwiper () 21 | 22 | @property (weak, readwrite, nonatomic) UIPanGestureRecognizer *panRecognizer; 23 | @property (weak, nonatomic) IBOutlet UINavigationController *navigationController; 24 | @property (strong, nonatomic) PanInteractiveTransition *interactionController; 25 | 26 | @property (strong, nonatomic) PanAnimator *animator; 27 | @property (assign, nonatomic) BOOL is_Should_Begain_Animation; //Default is NO; 28 | 29 | @end 30 | 31 | @implementation PanSwiper 32 | { 33 | PanGestureRecognizer_Direction _panDirection; //Default is 0; 34 | } 35 | 36 | - (void)dealloc 37 | { 38 | [_panRecognizer removeTarget:self action:@selector(handleWithPanGestureRecongizer:)]; 39 | [_navigationController.view removeGestureRecognizer:_panRecognizer]; 40 | } 41 | 42 | - (instancetype)initWithNavigationController:(UINavigationController *)navigationController 43 | { 44 | NSCParameterAssert(!!navigationController); 45 | 46 | self = [super init]; 47 | if (self) { 48 | _navigationController = navigationController; 49 | _navigationController.delegate = self; 50 | [self commonInit]; 51 | } 52 | return self; 53 | } 54 | 55 | - (void)awakeFromNib 56 | { 57 | [self commonInit]; 58 | } 59 | 60 | - (void)commonInit 61 | { 62 | UIGestureRecognizer *gesture = self.navigationController.interactivePopGestureRecognizer; 63 | gesture.enabled = NO; 64 | UIView *gestureView = gesture.view; 65 | 66 | UIPanGestureRecognizer *popRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleWithPanGestureRecongizer:)];; 67 | popRecognizer.maximumNumberOfTouches = 1; 68 | [gestureView addGestureRecognizer:popRecognizer]; 69 | self.panRecognizer = popRecognizer; 70 | 71 | self.is_Should_Begain_Animation = NO; 72 | } 73 | 74 | 75 | #pragma mark -- 偏移量、速度 -- 76 | //偏移量 77 | - (CGFloat)translationWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer 78 | { 79 | CGPoint point = [panGestureRecognizer translationInView:panGestureRecognizer.view]; 80 | CGFloat t_x = point.x; 81 | return t_x; 82 | } 83 | 84 | //速度 85 | - (CGFloat)velocityWithPanGestureRecongizer:(UIPanGestureRecognizer *)panGestureRecognizer 86 | { 87 | CGPoint point = [panGestureRecognizer velocityInView:panGestureRecognizer.view]; 88 | return point.x; 89 | } 90 | 91 | //更新拖拽方向 92 | - (CGFloat)updatePanDirection:(UIPanGestureRecognizer *)panGestureRecognizer 93 | { 94 | CGFloat velocity_x = [self velocityWithPanGestureRecongizer:panGestureRecognizer]; 95 | if (velocity_x > 0) { 96 | _panDirection = PanGestureRecognizer_Direction_Right; 97 | }else if (velocity_x < 0) { 98 | _panDirection = PanGestureRecognizer_Direction_Left; 99 | }else { 100 | _panDirection = PanGestureRecognizer_Direction_None; 101 | } 102 | 103 | return velocity_x; 104 | } 105 | 106 | 107 | #pragma mark -- PanGesture Response -- 108 | 109 | - (void)handleWithPanGestureRecongizer:(UIPanGestureRecognizer *)recognizer 110 | { 111 | CGFloat translation_x = [self translationWithPanGestureRecongizer:recognizer]; 112 | CGFloat progress = translation_x / recognizer.view.bounds.size.width; 113 | 114 | [self updatePanDirection:recognizer]; 115 | 116 | if (recognizer.state == UIGestureRecognizerStateBegan) { 117 | [self panGrBegan:recognizer]; 118 | } 119 | else if (recognizer.state == UIGestureRecognizerStateChanged) { 120 | [self panGrChanged:recognizer progress:progress]; 121 | } 122 | else { 123 | [self panGrEnded:recognizer progress:progress]; 124 | } 125 | } 126 | 127 | - (void)panGrBegan:(UIPanGestureRecognizer *)recognizer 128 | { 129 | self.animator = nil; 130 | self.interactionController = nil; 131 | 132 | if (PanGestureRecognizer_Direction_Right == _panDirection && !self.isForbidDragBack) { 133 | //Pop 134 | if (self.navigationController.viewControllers.count > 1) { 135 | [self createAnimatorAndTransitionWithPop:YES]; 136 | [self.navigationController popViewControllerAnimated:YES]; 137 | } 138 | } 139 | else if (PanGestureRecognizer_Direction_Left == _panDirection){ 140 | //Push 141 | UIViewController *nextController = [self nextController]; 142 | if (nextController) 143 | { 144 | [self createAnimatorAndTransitionWithPop:NO]; 145 | [self.navigationController pushViewController:nextController animated:YES]; 146 | } 147 | } 148 | } 149 | 150 | - (void)panGrChanged:(UIPanGestureRecognizer *)recognizer progress:(CGFloat)progress 151 | { 152 | if ([self.animator isKindOfClass:[PanPushAnimator class]]) { 153 | CGFloat temp_progress = ABS(progress); 154 | CGFloat panPush_progress = MIN(1.0, MAX(0.0, temp_progress)); 155 | if (progress > 0) { 156 | panPush_progress = 0.0f; 157 | } 158 | [self.interactionController updateInteractiveTransition:panPush_progress]; 159 | } 160 | else { 161 | if (!self.isForbidDragBack) { 162 | CGFloat panPop_progress = MIN(1.0, MAX(0.0, progress)); 163 | [self.interactionController updateInteractiveTransition:panPop_progress]; 164 | } 165 | } 166 | } 167 | 168 | - (void)panGrEnded:(UIPanGestureRecognizer *)recognizer progress:(CGFloat)progress 169 | { 170 | if (self.interactionController || self.animator) { 171 | //为了防止动画进行时再次重新拖拽,可在动画结束时设置为yes 172 | self.panRecognizer.enabled = NO; 173 | } 174 | 175 | CGFloat final_progress = 0.0; 176 | CGFloat k_Default = 0.0; 177 | if ([self.animator isKindOfClass:[PanPushAnimator class]]) { 178 | CGFloat temp_progress = ABS(progress); 179 | CGFloat panPush_progress = MIN(1.0, MAX(0.0, temp_progress)); 180 | if (progress > 0) { 181 | panPush_progress = 0.0f; 182 | } 183 | final_progress = panPush_progress; 184 | k_Default = k_Progress_Pan_Push; 185 | } 186 | else{ 187 | CGFloat panPop_progress = MIN(1.0, MAX(0.0, progress)); 188 | final_progress = panPop_progress; 189 | k_Default = k_Progress_Pan_Pop; 190 | } 191 | if (final_progress > k_Default) { 192 | [self.interactionController finishInteractiveTransition]; 193 | } 194 | else { 195 | [self.interactionController cancelInteractiveTransition]; 196 | } 197 | 198 | if (_panPushDelegate && [_panPushDelegate respondsToSelector:@selector(swiperDidEndPanPushToNextController:)]) { 199 | [self.panPushDelegate swiperDidEndPanPushToNextController:self]; 200 | } 201 | } 202 | 203 | - (UIViewController *)nextController 204 | { 205 | if (_panPushDelegate && [_panPushDelegate respondsToSelector:@selector(swiperBeginPanPushToNextController:)]) { 206 | UIViewController *nextController = [self.panPushDelegate swiperBeginPanPushToNextController:self]; 207 | if (nextController && [nextController isKindOfClass:[UIViewController class]]){ 208 | return nextController; 209 | } 210 | } 211 | return nil; 212 | } 213 | 214 | 215 | #pragma mark -- Animator start and end -- 216 | - (void)createAnimatorAndTransitionWithPop:(BOOL)isPop 217 | { 218 | if (isPop) { 219 | self.animator = [PanPopAnimator new]; 220 | }else { 221 | self.animator = [PanPushAnimator new]; 222 | } 223 | self.animator.delegate = self; 224 | 225 | self.interactionController = [PanInteractiveTransition new]; 226 | 227 | self.is_Should_Begain_Animation = YES; 228 | } 229 | 230 | - (void)animatorDidEnd 231 | { 232 | self.animator = nil; 233 | self.interactionController = nil; 234 | 235 | self.is_Should_Begain_Animation = NO; 236 | self.panRecognizer.enabled = YES; 237 | } 238 | 239 | 240 | #pragma mark -- PanAnimatorDelegate -- 241 | - (void)animator:(PanAnimator *)animator completeWithTransitionFinished:(BOOL)finish 242 | { 243 | [self animatorDidEnd]; 244 | } 245 | 246 | 247 | #pragma mark - UINavigationControllerDelegate - 248 | 249 | - (id)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC 250 | { 251 | if (self.is_Should_Begain_Animation && 252 | (operation == UINavigationControllerOperationPop || operation == UINavigationControllerOperationPush)){ 253 | return self.animator; 254 | } 255 | return nil; 256 | } 257 | 258 | - (id)navigationController:(UINavigationController *)navigationController interactionControllerForAnimationController:(id)animationController 259 | { 260 | if ([animationController isKindOfClass:[PanPopAnimator class]] || [animationController isKindOfClass:[PanPushAnimator class]]) { 261 | return self.interactionController; 262 | } 263 | return nil; 264 | } 265 | 266 | - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 267 | { 268 | self.is_Should_Begain_Animation = NO; 269 | } 270 | 271 | - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated 272 | { 273 | [self animatorDidEnd]; 274 | } 275 | 276 | @end 277 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Transition/PanInteractiveTransition.h: -------------------------------------------------------------------------------- 1 | // 2 | // PanInteractiveTransition.h 3 | // PanPush 4 | // 5 | // Created by Paddy-long on 16/3/19. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PanInteractiveTransition : UIPercentDrivenInteractiveTransition 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanNavigationController/PanSwiper/Transition/PanInteractiveTransition.m: -------------------------------------------------------------------------------- 1 | // 2 | // PanInteractiveTransition.m 3 | // PanPush 4 | // 5 | // Created by Paddy-long on 16/3/19. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "PanInteractiveTransition.h" 10 | 11 | @implementation PanInteractiveTransition 12 | 13 | - (instancetype)init{ 14 | self = [super init]; 15 | if (self) { 16 | [self setup]; 17 | } 18 | return self; 19 | } 20 | 21 | - (void)setup 22 | { 23 | self.completionCurve = UIViewAnimationCurveEaseInOut; 24 | } 25 | 26 | 27 | #pragma mark -- Events -- 28 | - (void)cancelInteractiveTransition; 29 | { 30 | [self resetTransitionSpeed:NO]; 31 | [super cancelInteractiveTransition]; 32 | } 33 | 34 | - (void)finishInteractiveTransition 35 | { 36 | [self resetTransitionSpeed:YES]; 37 | [super finishInteractiveTransition]; 38 | } 39 | 40 | - (void)resetTransitionSpeed:(BOOL)finish 41 | { 42 | CGFloat progress = self.percentComplete; 43 | CGFloat speed = 0.0f; 44 | if (finish) { 45 | speed = [self finishSpeedWithProgress:progress]; 46 | } 47 | else { 48 | speed = [self cancelSpeedWithProgress:progress]; 49 | } 50 | self.completionSpeed = speed; 51 | } 52 | 53 | #pragma mark -- Custom Speed -- 54 | - (CGFloat)finishSpeedWithProgress:(CGFloat)progress 55 | { 56 | if (progress < 0.3) { 57 | return 0.9; 58 | } 59 | else if (progress >= 0.3 && progress < 0.5) { 60 | return 0.8; 61 | } 62 | else if (progress >= 0.5 && progress < 0.7) { 63 | return 0.6; 64 | } 65 | else { 66 | return 0.5; 67 | } 68 | return 1.0; 69 | } 70 | 71 | - (CGFloat)cancelSpeedWithProgress:(CGFloat)progress 72 | { 73 | if (progress < 0.3) { 74 | return 0.5; 75 | } 76 | else if (progress >= 0.3 && progress < 0.5) { 77 | return 0.6; 78 | } 79 | else if (progress >= 0.5 && progress < 0.7) { 80 | return 0.8; 81 | } 82 | else { 83 | return 0.9; 84 | } 85 | return 1.0; 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /PanPush/PanPush/PanPush.pch: -------------------------------------------------------------------------------- 1 | // 2 | // PanPush.pch 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #ifndef PanPush_pch 10 | #define PanPush_pch 11 | 12 | #import 13 | #import 14 | 15 | #import "PanNavigationController.h" 16 | #import "FirstViewController.h" 17 | #import "SecondViewController.h" 18 | 19 | 20 | #ifdef DEBUG 21 | # define DLog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);} 22 | # define ELog(err) {if(err) DLog(@"%@", err)} 23 | #else 24 | # define DLog(...) 25 | # define ELog(err) 26 | #endif 27 | 28 | #endif /* PanPush_pch */ 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /PanPush/PanPush/SecondViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.h 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SecondViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /PanPush/PanPush/SecondViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SecondViewController.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import "SecondViewController.h" 10 | 11 | @interface SecondViewController () 12 | @property (weak, nonatomic) IBOutlet UILabel *label; 13 | 14 | @end 15 | 16 | @implementation SecondViewController 17 | 18 | - (void)viewDidAppear:(BOOL)animated 19 | { 20 | [super viewDidAppear:animated]; 21 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 22 | [nav setNextViewControllerDelegate:self]; 23 | } 24 | 25 | - (void)viewWillDisappear:(BOOL)animated 26 | { 27 | [super viewWillDisappear:animated]; 28 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 29 | [nav setNextViewControllerDelegate:nil]; 30 | } 31 | 32 | - (void)viewDidLoad { 33 | [super viewDidLoad]; 34 | 35 | NSInteger count = self.navigationController.viewControllers.count; 36 | NSString *name = NSStringFromClass([self class]); 37 | self.label.text = [NSString stringWithFormat:@"第 %@ 个\n%@",@(count),name]; 38 | } 39 | 40 | 41 | - (IBAction)push:(id)sender { 42 | FirstViewController *controller = [[FirstViewController alloc] initWithNibName:NSStringFromClass([FirstViewController class]) bundle:nil]; 43 | [self.navigationController pushViewController:controller animated:YES]; 44 | } 45 | 46 | - (IBAction)popToRoot:(id)sender { 47 | NSInteger count = self.navigationController.viewControllers.count; 48 | if (count > 1) { 49 | [self.navigationController popToRootViewControllerAnimated:YES]; 50 | } 51 | } 52 | 53 | 54 | #pragma mark -- PanSwiper Delegate -- 55 | - (UIViewController *)swiperBeginPanPushToNextController:(PanSwiper *)swiper 56 | { 57 | FirstViewController *controller = [[FirstViewController alloc] initWithNibName:NSStringFromClass([FirstViewController class]) bundle:nil]; 58 | return controller; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /PanPush/PanPush/SecondViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 41 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /PanPush/PanPush/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PanPush 4 | // 5 | // Created by lpc on 16/3/16. 6 | // Copyright © 2016年 lpc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PanPush_NavigationController 2 | 为UINavigationController添加右滑Pop、左滑Push出ViewController的功能,集成非常简单. 3 | 4 | ### 1.How to use 5 | ``` 6 | 使用or继承Demo中提供的`PanNavigationController`即可 7 | ``` 8 | 9 | ### 2.右滑Pop返回 10 | 因为右滑返回功能是默认开启的,如果需要在某一个页面关闭,需要在此`Controller`的生命周期方法中设置,但因为`UINavigationController`是全局的,所以在此`Controller`消失的时候再设置打开,因为其他`Controller`很有可能会使用此功能(用户亦可根据自己的使用场景设置开启or关闭时机) 11 | 12 | ``` 13 | //关闭右滑返回功能 14 | - (void)viewDidAppear:(BOOL)animated 15 | { 16 | [super viewDidAppear:animated]; 17 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 18 | nav.isForbidDragBack = YES; 19 | } 20 | 21 | //开启右滑返回功能 22 | - (void)viewWillDisappear:(BOOL)animated 23 | { 24 | [super viewWillDisappear:animated]; 25 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 26 | nav.isForbidDragBack = NO; 27 | } 28 | 29 | ``` 30 | 31 | ### 3.左滑Push 32 | 此功能是参照`网易新闻App`在`新闻详情页`,左滑push出`评论列表页面`的实现方式. 33 | 34 | 因为在`UINavigationController`导航堆栈中,我们根本不知道即将push出的是哪一个`Controller`,so,在某个`Controler`中要使用此功能时,必须设置`delegate`,并实现其代理方法,指定其左滑push出的新的`Controller`. 35 | 36 | ``` 37 | @interface SecondViewController () 38 | ``` 39 | 40 | 既然`UINavigationController`是全局的,所以在此`Controller`消失的时候需要关闭此功能(用户亦可根据自己的使用场景设置开启or关闭时机) 41 | 42 | ``` 43 | //开启左滑push功能,设置代理,实现其代理方法 44 | - (void)viewDidAppear:(BOOL)animated 45 | { 46 | [super viewDidAppear:animated]; 47 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 48 | [nav setNextViewControllerDelegate:self]; 49 | } 50 | 51 | //关闭左滑push 52 | - (void)viewWillDisappear:(BOOL)animated 53 | { 54 | [super viewWillDisappear:animated]; 55 | PanNavigationController *nav = (PanNavigationController *)self.navigationController; 56 | [nav setNextViewControllerDelegate:nil]; 57 | } 58 | 59 | ``` 60 | 61 | 指定通过左滑push功能推出的新的Controller 62 | 63 | ``` 64 | #pragma mark -- PanSwiper Delegate -- 65 | - (UIViewController *)swiperBeginPanPushToNextController:(PanSwiper *)swiper 66 | { 67 | FirstViewController *controller = [[FirstViewController alloc] initWithNibName:NSStringFromClass([FirstViewController class]) bundle:nil]; 68 | return controller; 69 | } 70 | ``` 71 |
72 | 73 | ![Demo Gif](PanPush.gif) 74 | --------------------------------------------------------------------------------