├── .gitignore ├── DYLeftSlipManager ├── DYLeftSlipManager.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── DYLeftSlipManager │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── BaseViewController.h │ ├── BaseViewController.m │ ├── DYLeftSlipManager │ ├── DYLeftSlipManager.h │ └── DYLeftSlipManager.m │ ├── Info.plist │ ├── LeftTableViewController.h │ ├── LeftTableViewController.m │ ├── TabbarController.h │ ├── TabbarController.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── DYLeftSlipManagerGIF.gif └── 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 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 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/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | AF3E37B81DD36D1A0092B574 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3E37B71DD36D1A0092B574 /* main.m */; }; 11 | AF3E37BB1DD36D1A0092B574 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3E37BA1DD36D1A0092B574 /* AppDelegate.m */; }; 12 | AF3E37BE1DD36D1A0092B574 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3E37BD1DD36D1A0092B574 /* ViewController.m */; }; 13 | AF3E37C11DD36D1A0092B574 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AF3E37BF1DD36D1A0092B574 /* Main.storyboard */; }; 14 | AF3E37C31DD36D1A0092B574 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AF3E37C21DD36D1A0092B574 /* Assets.xcassets */; }; 15 | AF3E37C61DD36D1A0092B574 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AF3E37C41DD36D1A0092B574 /* LaunchScreen.storyboard */; }; 16 | AF3E37D01DD36D620092B574 /* DYLeftSlipManager.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3E37CF1DD36D620092B574 /* DYLeftSlipManager.m */; }; 17 | AF3E37D31DD36E400092B574 /* TabbarController.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3E37D21DD36E400092B574 /* TabbarController.m */; }; 18 | AF3E37D61DD36E580092B574 /* LeftTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3E37D51DD36E580092B574 /* LeftTableViewController.m */; }; 19 | AFCBCEAD1E9DFA0B00527A5D /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AFCBCEAC1E9DFA0B00527A5D /* BaseViewController.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | AF3E37B31DD36D1A0092B574 /* DYLeftSlipManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DYLeftSlipManager.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | AF3E37B71DD36D1A0092B574 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 25 | AF3E37B91DD36D1A0092B574 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 26 | AF3E37BA1DD36D1A0092B574 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 27 | AF3E37BC1DD36D1A0092B574 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 28 | AF3E37BD1DD36D1A0092B574 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 29 | AF3E37C01DD36D1A0092B574 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 30 | AF3E37C21DD36D1A0092B574 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 31 | AF3E37C51DD36D1A0092B574 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 32 | AF3E37C71DD36D1A0092B574 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | AF3E37CE1DD36D620092B574 /* DYLeftSlipManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DYLeftSlipManager.h; sourceTree = ""; }; 34 | AF3E37CF1DD36D620092B574 /* DYLeftSlipManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DYLeftSlipManager.m; sourceTree = ""; }; 35 | AF3E37D11DD36E400092B574 /* TabbarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TabbarController.h; sourceTree = ""; }; 36 | AF3E37D21DD36E400092B574 /* TabbarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TabbarController.m; sourceTree = ""; }; 37 | AF3E37D41DD36E580092B574 /* LeftTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeftTableViewController.h; sourceTree = ""; }; 38 | AF3E37D51DD36E580092B574 /* LeftTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeftTableViewController.m; sourceTree = ""; }; 39 | AFCBCEAB1E9DFA0B00527A5D /* BaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseViewController.h; sourceTree = ""; }; 40 | AFCBCEAC1E9DFA0B00527A5D /* BaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseViewController.m; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | AF3E37B01DD36D1A0092B574 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | /* End PBXFrameworksBuildPhase section */ 52 | 53 | /* Begin PBXGroup section */ 54 | AF3E37AA1DD36D1A0092B574 = { 55 | isa = PBXGroup; 56 | children = ( 57 | AF3E37B51DD36D1A0092B574 /* DYLeftSlipManager */, 58 | AF3E37B41DD36D1A0092B574 /* Products */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | AF3E37B41DD36D1A0092B574 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | AF3E37B31DD36D1A0092B574 /* DYLeftSlipManager.app */, 66 | ); 67 | name = Products; 68 | sourceTree = ""; 69 | }; 70 | AF3E37B51DD36D1A0092B574 /* DYLeftSlipManager */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | AF3E37CD1DD36D390092B574 /* DYLeftSlipManager */, 74 | AF3E37B91DD36D1A0092B574 /* AppDelegate.h */, 75 | AF3E37BA1DD36D1A0092B574 /* AppDelegate.m */, 76 | AF3E37BC1DD36D1A0092B574 /* ViewController.h */, 77 | AF3E37BD1DD36D1A0092B574 /* ViewController.m */, 78 | AF3E37D11DD36E400092B574 /* TabbarController.h */, 79 | AF3E37D21DD36E400092B574 /* TabbarController.m */, 80 | AF3E37D41DD36E580092B574 /* LeftTableViewController.h */, 81 | AF3E37D51DD36E580092B574 /* LeftTableViewController.m */, 82 | AF3E37BF1DD36D1A0092B574 /* Main.storyboard */, 83 | AF3E37C21DD36D1A0092B574 /* Assets.xcassets */, 84 | AF3E37C41DD36D1A0092B574 /* LaunchScreen.storyboard */, 85 | AF3E37C71DD36D1A0092B574 /* Info.plist */, 86 | AF3E37B61DD36D1A0092B574 /* Supporting Files */, 87 | AFCBCEAB1E9DFA0B00527A5D /* BaseViewController.h */, 88 | AFCBCEAC1E9DFA0B00527A5D /* BaseViewController.m */, 89 | ); 90 | path = DYLeftSlipManager; 91 | sourceTree = ""; 92 | }; 93 | AF3E37B61DD36D1A0092B574 /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | AF3E37B71DD36D1A0092B574 /* main.m */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | AF3E37CD1DD36D390092B574 /* DYLeftSlipManager */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | AF3E37CE1DD36D620092B574 /* DYLeftSlipManager.h */, 105 | AF3E37CF1DD36D620092B574 /* DYLeftSlipManager.m */, 106 | ); 107 | path = DYLeftSlipManager; 108 | sourceTree = ""; 109 | }; 110 | /* End PBXGroup section */ 111 | 112 | /* Begin PBXNativeTarget section */ 113 | AF3E37B21DD36D1A0092B574 /* DYLeftSlipManager */ = { 114 | isa = PBXNativeTarget; 115 | buildConfigurationList = AF3E37CA1DD36D1A0092B574 /* Build configuration list for PBXNativeTarget "DYLeftSlipManager" */; 116 | buildPhases = ( 117 | AF3E37AF1DD36D1A0092B574 /* Sources */, 118 | AF3E37B01DD36D1A0092B574 /* Frameworks */, 119 | AF3E37B11DD36D1A0092B574 /* Resources */, 120 | ); 121 | buildRules = ( 122 | ); 123 | dependencies = ( 124 | ); 125 | name = DYLeftSlipManager; 126 | productName = DYLeftSlipManager; 127 | productReference = AF3E37B31DD36D1A0092B574 /* DYLeftSlipManager.app */; 128 | productType = "com.apple.product-type.application"; 129 | }; 130 | /* End PBXNativeTarget section */ 131 | 132 | /* Begin PBXProject section */ 133 | AF3E37AB1DD36D1A0092B574 /* Project object */ = { 134 | isa = PBXProject; 135 | attributes = { 136 | LastUpgradeCheck = 0810; 137 | ORGANIZATIONNAME = DY; 138 | TargetAttributes = { 139 | AF3E37B21DD36D1A0092B574 = { 140 | CreatedOnToolsVersion = 8.1; 141 | DevelopmentTeam = JM8FC59923; 142 | ProvisioningStyle = Automatic; 143 | }; 144 | }; 145 | }; 146 | buildConfigurationList = AF3E37AE1DD36D1A0092B574 /* Build configuration list for PBXProject "DYLeftSlipManager" */; 147 | compatibilityVersion = "Xcode 3.2"; 148 | developmentRegion = English; 149 | hasScannedForEncodings = 0; 150 | knownRegions = ( 151 | English, 152 | en, 153 | Base, 154 | ); 155 | mainGroup = AF3E37AA1DD36D1A0092B574; 156 | productRefGroup = AF3E37B41DD36D1A0092B574 /* Products */; 157 | projectDirPath = ""; 158 | projectRoot = ""; 159 | targets = ( 160 | AF3E37B21DD36D1A0092B574 /* DYLeftSlipManager */, 161 | ); 162 | }; 163 | /* End PBXProject section */ 164 | 165 | /* Begin PBXResourcesBuildPhase section */ 166 | AF3E37B11DD36D1A0092B574 /* Resources */ = { 167 | isa = PBXResourcesBuildPhase; 168 | buildActionMask = 2147483647; 169 | files = ( 170 | AF3E37C61DD36D1A0092B574 /* LaunchScreen.storyboard in Resources */, 171 | AF3E37C31DD36D1A0092B574 /* Assets.xcassets in Resources */, 172 | AF3E37C11DD36D1A0092B574 /* Main.storyboard in Resources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXResourcesBuildPhase section */ 177 | 178 | /* Begin PBXSourcesBuildPhase section */ 179 | AF3E37AF1DD36D1A0092B574 /* Sources */ = { 180 | isa = PBXSourcesBuildPhase; 181 | buildActionMask = 2147483647; 182 | files = ( 183 | AF3E37BE1DD36D1A0092B574 /* ViewController.m in Sources */, 184 | AF3E37D01DD36D620092B574 /* DYLeftSlipManager.m in Sources */, 185 | AF3E37BB1DD36D1A0092B574 /* AppDelegate.m in Sources */, 186 | AF3E37D31DD36E400092B574 /* TabbarController.m in Sources */, 187 | AF3E37D61DD36E580092B574 /* LeftTableViewController.m in Sources */, 188 | AFCBCEAD1E9DFA0B00527A5D /* BaseViewController.m in Sources */, 189 | AF3E37B81DD36D1A0092B574 /* main.m in Sources */, 190 | ); 191 | runOnlyForDeploymentPostprocessing = 0; 192 | }; 193 | /* End PBXSourcesBuildPhase section */ 194 | 195 | /* Begin PBXVariantGroup section */ 196 | AF3E37BF1DD36D1A0092B574 /* Main.storyboard */ = { 197 | isa = PBXVariantGroup; 198 | children = ( 199 | AF3E37C01DD36D1A0092B574 /* Base */, 200 | ); 201 | name = Main.storyboard; 202 | sourceTree = ""; 203 | }; 204 | AF3E37C41DD36D1A0092B574 /* LaunchScreen.storyboard */ = { 205 | isa = PBXVariantGroup; 206 | children = ( 207 | AF3E37C51DD36D1A0092B574 /* Base */, 208 | ); 209 | name = LaunchScreen.storyboard; 210 | sourceTree = ""; 211 | }; 212 | /* End PBXVariantGroup section */ 213 | 214 | /* Begin XCBuildConfiguration section */ 215 | AF3E37C81DD36D1A0092B574 /* Debug */ = { 216 | isa = XCBuildConfiguration; 217 | buildSettings = { 218 | ALWAYS_SEARCH_USER_PATHS = NO; 219 | CLANG_ANALYZER_NONNULL = YES; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 221 | CLANG_CXX_LIBRARY = "libc++"; 222 | CLANG_ENABLE_MODULES = YES; 223 | CLANG_ENABLE_OBJC_ARC = YES; 224 | CLANG_WARN_BOOL_CONVERSION = YES; 225 | CLANG_WARN_CONSTANT_CONVERSION = YES; 226 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 227 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 228 | CLANG_WARN_EMPTY_BODY = YES; 229 | CLANG_WARN_ENUM_CONVERSION = YES; 230 | CLANG_WARN_INFINITE_RECURSION = YES; 231 | CLANG_WARN_INT_CONVERSION = YES; 232 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 233 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 234 | CLANG_WARN_UNREACHABLE_CODE = YES; 235 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 236 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 237 | COPY_PHASE_STRIP = NO; 238 | DEBUG_INFORMATION_FORMAT = dwarf; 239 | ENABLE_STRICT_OBJC_MSGSEND = YES; 240 | ENABLE_TESTABILITY = YES; 241 | GCC_C_LANGUAGE_STANDARD = gnu99; 242 | GCC_DYNAMIC_NO_PIC = NO; 243 | GCC_NO_COMMON_BLOCKS = YES; 244 | GCC_OPTIMIZATION_LEVEL = 0; 245 | GCC_PREPROCESSOR_DEFINITIONS = ( 246 | "DEBUG=1", 247 | "$(inherited)", 248 | ); 249 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 250 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 251 | GCC_WARN_UNDECLARED_SELECTOR = YES; 252 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 253 | GCC_WARN_UNUSED_FUNCTION = YES; 254 | GCC_WARN_UNUSED_VARIABLE = YES; 255 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 256 | MTL_ENABLE_DEBUG_INFO = YES; 257 | ONLY_ACTIVE_ARCH = YES; 258 | SDKROOT = iphoneos; 259 | }; 260 | name = Debug; 261 | }; 262 | AF3E37C91DD36D1A0092B574 /* Release */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ALWAYS_SEARCH_USER_PATHS = NO; 266 | CLANG_ANALYZER_NONNULL = YES; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_MODULES = YES; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_CONSTANT_CONVERSION = YES; 273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 274 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 275 | CLANG_WARN_EMPTY_BODY = YES; 276 | CLANG_WARN_ENUM_CONVERSION = YES; 277 | CLANG_WARN_INFINITE_RECURSION = YES; 278 | CLANG_WARN_INT_CONVERSION = YES; 279 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 280 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 281 | CLANG_WARN_UNREACHABLE_CODE = YES; 282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 284 | COPY_PHASE_STRIP = NO; 285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 286 | ENABLE_NS_ASSERTIONS = NO; 287 | ENABLE_STRICT_OBJC_MSGSEND = YES; 288 | GCC_C_LANGUAGE_STANDARD = gnu99; 289 | GCC_NO_COMMON_BLOCKS = YES; 290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 292 | GCC_WARN_UNDECLARED_SELECTOR = YES; 293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 294 | GCC_WARN_UNUSED_FUNCTION = YES; 295 | GCC_WARN_UNUSED_VARIABLE = YES; 296 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 297 | MTL_ENABLE_DEBUG_INFO = NO; 298 | SDKROOT = iphoneos; 299 | VALIDATE_PRODUCT = YES; 300 | }; 301 | name = Release; 302 | }; 303 | AF3E37CB1DD36D1A0092B574 /* Debug */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 307 | CURRENT_PROJECT_VERSION = 1.3.1; 308 | DEVELOPMENT_TEAM = JM8FC59923; 309 | INFOPLIST_FILE = DYLeftSlipManager/Info.plist; 310 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 311 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 312 | MARKETING_VERSION = 1.3; 313 | PRODUCT_BUNDLE_IDENTIFIER = com.dy.DYLeftSlipManager; 314 | PRODUCT_NAME = "$(TARGET_NAME)"; 315 | }; 316 | name = Debug; 317 | }; 318 | AF3E37CC1DD36D1A0092B574 /* Release */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 322 | CURRENT_PROJECT_VERSION = 1.3.1; 323 | DEVELOPMENT_TEAM = JM8FC59923; 324 | INFOPLIST_FILE = DYLeftSlipManager/Info.plist; 325 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 326 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 327 | MARKETING_VERSION = 1.3; 328 | PRODUCT_BUNDLE_IDENTIFIER = com.dy.DYLeftSlipManager; 329 | PRODUCT_NAME = "$(TARGET_NAME)"; 330 | }; 331 | name = Release; 332 | }; 333 | /* End XCBuildConfiguration section */ 334 | 335 | /* Begin XCConfigurationList section */ 336 | AF3E37AE1DD36D1A0092B574 /* Build configuration list for PBXProject "DYLeftSlipManager" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | AF3E37C81DD36D1A0092B574 /* Debug */, 340 | AF3E37C91DD36D1A0092B574 /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | AF3E37CA1DD36D1A0092B574 /* Build configuration list for PBXNativeTarget "DYLeftSlipManager" */ = { 346 | isa = XCConfigurationList; 347 | buildConfigurations = ( 348 | AF3E37CB1DD36D1A0092B574 /* Debug */, 349 | AF3E37CC1DD36D1A0092B574 /* Release */, 350 | ); 351 | defaultConfigurationIsVisible = 0; 352 | defaultConfigurationName = Release; 353 | }; 354 | /* End XCConfigurationList section */ 355 | }; 356 | rootObject = AF3E37AB1DD36D1A0092B574 /* Project object */; 357 | } 358 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DYLeftSlipManager 4 | // 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DYLeftSlipManager 4 | // 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 18 | return YES; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/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 | } -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/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 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/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 | 31 | 38 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/BaseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.h 3 | // DYLeftSlipManager 4 | // 该控制器是自定义返回按钮的控制器 5 | // Created by 戴奕 on 2017/4/12. 6 | // Copyright © 2017年 DY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/BaseViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.m 3 | // DYLeftSlipManager 4 | // 该控制器是自定义返回按钮的控制器 5 | // Created by 戴奕 on 2017/4/12. 6 | // Copyright © 2017年 DY. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | 11 | @interface BaseViewController () 12 | 13 | @end 14 | 15 | @implementation BaseViewController 16 | 17 | - (void)viewDidLoad { 18 | [super viewDidLoad]; 19 | self.view.backgroundColor = [UIColor brownColor]; 20 | 21 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"myBack" style:UIBarButtonItemStyleDone target:self action:@selector(popAction)]; 22 | self.navigationController.interactivePopGestureRecognizer.enabled = YES; 23 | self.navigationController.interactivePopGestureRecognizer.delegate = self; 24 | 25 | UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 100)]; 26 | [btn setTitle:@"点我再push一个页面" forState:UIControlStateNormal]; 27 | [btn addTarget:self action:@selector(pushAction) forControlEvents:UIControlEventTouchUpInside]; 28 | [self.view addSubview:btn]; 29 | 30 | 31 | UIButton *dismissbBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 100)]; 32 | [dismissbBtn setTitle:@"dismiss整个导航栏" forState:UIControlStateNormal]; 33 | [dismissbBtn addTarget:self action:@selector(dismissAction) forControlEvents:UIControlEventTouchUpInside]; 34 | [self.view addSubview:dismissbBtn]; 35 | } 36 | 37 | - (void)popAction { 38 | [self.navigationController popViewControllerAnimated:YES]; 39 | } 40 | 41 | - (void)pushAction { 42 | [self.navigationController pushViewController:[self.class new] animated:YES]; 43 | } 44 | 45 | - (void)dismissAction { 46 | [self.navigationController dismissViewControllerAnimated:YES completion:^{ 47 | 48 | }]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/DYLeftSlipManager/DYLeftSlipManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // DYLeftSlipManager.h 3 | // DYLeftSlipManager 4 | // 左滑管理器 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DYLeftSlipManager : UIPercentDrivenInteractiveTransition 12 | 13 | /** 14 | * @brief 单例方法 15 | * @return instancetype DYLeftSlipManager左滑管理器实例 16 | */ 17 | + (instancetype)sharedManager; 18 | 19 | /** 20 | * @brief 设置左滑视图及主视图 21 | * @param leftViewController 左侧菜单视图控制器 22 | * @param coverViewController 主控制器 23 | */ 24 | - (void)setLeftViewController:(UIViewController *)leftViewController coverViewController:(UIViewController *)coverViewController; 25 | 26 | /** 27 | * @brief 显示左滑视图 28 | */ 29 | - (void)showLeftView; 30 | 31 | /** 32 | * @brief 取消显示侧滑视图 33 | */ 34 | - (void)dismissLeftView; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/DYLeftSlipManager/DYLeftSlipManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // DYLeftSlipManager.m 3 | // DYLeftSlipManager 4 | // 左滑管理器 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import "DYLeftSlipManager.h" 10 | #import 11 | 12 | @interface UINavigationController (DYLM_Push) 13 | 14 | + (void)swizzlingPushAndPop; 15 | 16 | @end 17 | 18 | static const void *DYLM_PushStateObserveKey = &DYLM_PushStateObserveKey; 19 | 20 | @interface UIScreenEdgePanGestureRecognizer (DYLM_Push) 21 | 22 | @property (nonatomic, weak) id stateObserve; 23 | 24 | @end 25 | 26 | @implementation UIScreenEdgePanGestureRecognizer (DYLM_Push) 27 | 28 | - (void)setStateObserve:(id)stateObserve { 29 | objc_setAssociatedObject(self, DYLM_PushStateObserveKey, stateObserve, OBJC_ASSOCIATION_ASSIGN); 30 | } 31 | 32 | - (id)stateObserve { 33 | return objc_getAssociatedObject(self, DYLM_PushStateObserveKey); 34 | } 35 | 36 | @end 37 | 38 | // 单例对象 39 | static DYLeftSlipManager *_leftSlipManager = nil; 40 | // 手势轻扫临界速度 41 | CGFloat const DYLeftSlipCriticalVelocity = 800; 42 | // 左滑手势触发距离 43 | CGFloat const DYLeftSlipLeftSlipPanTriggerWidth = 50; 44 | 45 | @interface DYLeftSlipManager () 46 | /** 是否已经显示左滑视图 */ 47 | @property (nonatomic, assign) BOOL showLeft; 48 | /** 点击返回的遮罩view */ 49 | @property (nonatomic, strong) UIView *tapView; 50 | /** 是否在交互中 */ 51 | @property (nonatomic, assign) BOOL interactive; 52 | /** present or dismiss */ 53 | @property (nonatomic, assign) BOOL present; 54 | /** 左滑视图宽度 */ 55 | @property (nonatomic, assign) CGFloat leftViewWidth; 56 | 57 | @property (nonatomic, strong) UIViewController *leftVC; 58 | @property (nonatomic, weak) UIViewController *coverVC; 59 | 60 | /** 侧滑手势 */ 61 | @property (nonatomic, strong) UIPanGestureRecognizer *panGesture; 62 | 63 | /** 待处理的navigationController */ 64 | 65 | @end 66 | 67 | @implementation DYLeftSlipManager 68 | 69 | #pragma mark - 单例方法 70 | + (instancetype)sharedManager { 71 | static dispatch_once_t onceToken; 72 | dispatch_once(&onceToken, ^{ 73 | _leftSlipManager = [[self alloc] init]; 74 | _leftSlipManager.leftViewWidth = [UIScreen mainScreen].bounds.size.width * 0.8; 75 | }); 76 | return _leftSlipManager; 77 | } 78 | 79 | + (instancetype)allocWithZone:(struct _NSZone *)zone { 80 | static dispatch_once_t onceToken; 81 | dispatch_once(&onceToken, ^{ 82 | _leftSlipManager = [super allocWithZone:zone]; 83 | }); 84 | return _leftSlipManager; 85 | } 86 | 87 | - (id)copyWithZone:(NSZone *)zone { 88 | return _leftSlipManager; 89 | } 90 | 91 | #pragma mark - 初始化方法 92 | - (instancetype)init { 93 | if (self = [super init]) { 94 | self.completionCurve = UIViewAnimationCurveLinear; 95 | } 96 | return self; 97 | } 98 | 99 | #pragma mark - public Methods 100 | - (void)setLeftViewController:(UIViewController *)leftViewController coverViewController:(UIViewController *)coverViewController { 101 | self.leftVC = leftViewController; 102 | self.coverVC = coverViewController; 103 | 104 | [self.coverVC.view addSubview:self.tapView]; 105 | 106 | // 转场代理 107 | self.leftVC.transitioningDelegate = self; 108 | // 侧滑手势 109 | [self.coverVC.view addGestureRecognizer:self.panGesture]; 110 | 111 | [UINavigationController swizzlingPushAndPop]; 112 | } 113 | 114 | - (void)showLeftView { 115 | self.leftVC.modalPresentationStyle = UIModalPresentationFullScreen; 116 | [self.coverVC presentViewController:self.leftVC animated:YES completion:nil]; 117 | } 118 | 119 | - (void)dismissLeftView { 120 | dispatch_async(dispatch_get_main_queue(), ^{ 121 | [self.leftVC dismissViewControllerAnimated:YES completion:nil]; 122 | }); 123 | } 124 | 125 | #pragma mark - private Methods 126 | /** 127 | * @brief 设置滑动手势是否可用 128 | * @param enabled 可用状态 129 | */ 130 | - (void)setGestureEnabled:(BOOL)enabled { 131 | self.panGesture.enabled = enabled; 132 | } 133 | 134 | /** 135 | * @brief 是否需要拦截UINavigationController 136 | * @param viewController 需要判断的VC 137 | * @return BOOL YES代表通过拦截,NO代表被拦截 138 | */ 139 | - (BOOL)shouldInterceptNaviVC:(UIViewController *)viewController { 140 | if ([viewController isKindOfClass:UINavigationController.class]) { 141 | UINavigationController *naviVC = (UINavigationController *)viewController; 142 | return naviVC.viewControllers.count == 1; 143 | } 144 | return YES; 145 | } 146 | 147 | /** 148 | * @brief 是否启用Pan手势 149 | * @return BOOL Pan手势是否可用 150 | * @discussion 防止导航栏push了新视图后,更改右滑手势导致侧滑出菜单 151 | */ 152 | - (BOOL)shouldPanGestureEnabled { 153 | // 判断self.coverVC是否是UINavigationController 154 | BOOL naviAspectResult = [self shouldInterceptNaviVC:self.coverVC]; 155 | if (!naviAspectResult) { 156 | return NO; 157 | } 158 | 159 | // 判断self.coverVC是否是UITabBarController,再判断当前的子控制器是否是UINavigationController 160 | if ([self.coverVC isKindOfClass:UITabBarController.class]) { 161 | UITabBarController *tabBarVC = (UITabBarController *)self.coverVC; 162 | UIViewController *selectVC = tabBarVC.selectedViewController; 163 | return [self shouldInterceptNaviVC:selectVC]; 164 | } 165 | 166 | return YES; 167 | } 168 | 169 | #pragma mark - 手势处理方法 170 | - (void)pan:(UIPanGestureRecognizer *)pan { 171 | if (![self shouldPanGestureEnabled]) { 172 | [self setGestureEnabled:NO]; 173 | return; 174 | } 175 | // X轴偏移 176 | CGFloat offsetX = [pan translationInView:pan.view].x; 177 | // X轴速度 178 | CGFloat velocityX = [pan velocityInView:pan.view].x; 179 | 180 | CGFloat percent; 181 | if (self.showLeft) { 182 | // 坑点。千万不要超过1 183 | percent = MIN(-offsetX / self.leftViewWidth, 1); 184 | } else { 185 | percent = MIN(offsetX / self.leftViewWidth, 1); 186 | } 187 | 188 | switch (pan.state) { 189 | case UIGestureRecognizerStateBegan: 190 | { 191 | self.interactive = YES; 192 | if (self.showLeft) { 193 | [self dismissLeftView]; 194 | } else { 195 | [self showLeftView]; 196 | } 197 | } 198 | break; 199 | case UIGestureRecognizerStateChanged: 200 | { 201 | [self updateInteractiveTransition:percent]; 202 | } 203 | break; 204 | case UIGestureRecognizerStateEnded: 205 | case UIGestureRecognizerStateCancelled: 206 | { 207 | self.interactive = NO; 208 | 209 | // 判断是否需要转场 210 | BOOL shouldTransition = NO; 211 | 212 | // 1.present时 213 | // 1.1 速度正方向,>800,则正向转场 214 | // 1.2 速度反向时,<-800,则反向转场 215 | // 1.3 速度正向<800 或者 速度反向>-800, 判断percent是否大于0.5 216 | if (!self.showLeft) { 217 | if (velocityX > 0) { 218 | if (velocityX > DYLeftSlipCriticalVelocity) { 219 | shouldTransition = YES; 220 | } else { 221 | shouldTransition = percent > 0.5; 222 | } 223 | } else { 224 | if (velocityX < -DYLeftSlipCriticalVelocity) { 225 | shouldTransition = NO; 226 | } else { 227 | shouldTransition = percent > 0.5; 228 | } 229 | } 230 | } else { 231 | if (velocityX < 0) { 232 | if (velocityX < -DYLeftSlipCriticalVelocity) { 233 | shouldTransition = YES; 234 | } else { 235 | shouldTransition = percent > 0.5; 236 | } 237 | } else { 238 | if (velocityX > DYLeftSlipCriticalVelocity) { 239 | shouldTransition = NO; 240 | } else { 241 | shouldTransition = percent > 0.5; 242 | } 243 | } 244 | } 245 | 246 | // 2.dismiss时 247 | // 2.1 速度正向,<-800,则正向转场 248 | // 2.2 速度反向,>800,则反向转场 249 | // 2.3 速度正向>-800 或者 速度反向<800,判断percent是否大于0.5 250 | if (shouldTransition) { 251 | [self finishInteractiveTransition]; 252 | } else { 253 | [self cancelInteractiveTransition]; 254 | } 255 | } 256 | break; 257 | default: 258 | break; 259 | } 260 | } 261 | 262 | #pragma mark - UIGestureRecognizerDelegate Methods 263 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { 264 | if (self.showLeft) { 265 | return YES; 266 | } 267 | 268 | UIPanGestureRecognizer *panGesture = (UIPanGestureRecognizer *)gestureRecognizer; 269 | 270 | // 忽略起始点不在左侧触发范围内的手势 271 | CGFloat touchBeganX = [panGesture locationInView:panGesture.view].x; 272 | if (touchBeganX > DYLeftSlipLeftSlipPanTriggerWidth) { 273 | return NO; 274 | } 275 | 276 | // 忽略反向手势 277 | CGPoint translation = [panGesture translationInView:panGesture.view]; 278 | if (translation.x <= 0) { 279 | return NO; 280 | } 281 | 282 | return YES; 283 | } 284 | 285 | #pragma mark - UIViewControllerTransitioningDelegate代理方法 286 | - (nullable id )animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source { 287 | self.present = YES; 288 | return self; 289 | } 290 | 291 | - (nullable id )animationControllerForDismissedController:(UIViewController *)dismissed { 292 | self.present = NO; 293 | return self; 294 | } 295 | 296 | - (id)interactionControllerForDismissal:(id)animator { 297 | return self.interactive ? self : nil; 298 | } 299 | 300 | - (id)interactionControllerForPresentation:(id)animator { 301 | return self.interactive ? self : nil; 302 | } 303 | 304 | #pragma mark - UIViewControllerAnimatedTransitioning代理方法 305 | - (NSTimeInterval)transitionDuration:(id)transitionContext { 306 | return .3f; 307 | } 308 | 309 | - (void)animateTransition:(id)transitionContext { 310 | if (self.present) { 311 | // 基础操作,获取两个VC并把视图加在容器上 312 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 313 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 314 | 315 | UIView *containerView = [transitionContext containerView]; 316 | toVC.view.frame = CGRectMake(0, 0, self.leftViewWidth, containerView.frame.size.height); 317 | [containerView addSubview:toVC.view]; 318 | [containerView sendSubviewToBack:toVC.view]; 319 | 320 | // 将tapView提前,防止pop回来将tabbar提前 321 | [self.tapView.superview bringSubviewToFront:self.tapView]; 322 | 323 | // 动画block 324 | void(^animateBlock)() = ^{ 325 | fromVC.view.frame = CGRectMake(self.leftViewWidth, 0, fromVC.view.frame.size.width, fromVC.view.frame.size.height); 326 | self.tapView.alpha = 1.f; 327 | }; 328 | 329 | // 动画完成block 330 | void(^completeBlock)() = ^{ 331 | if ([transitionContext transitionWasCancelled]) { 332 | [transitionContext completeTransition:NO]; 333 | } else { 334 | [transitionContext completeTransition:YES]; 335 | [containerView addSubview:fromVC.view]; 336 | 337 | // 加上点击dismiss的View 338 | // [fromVC.view addSubview:self.tapView]; 339 | self.showLeft = YES; 340 | } 341 | }; 342 | 343 | // 手势和普通动画做区别 344 | if (self.interactive) { 345 | // 呵呵🙃 346 | [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ 347 | animateBlock(); 348 | } completion:^(BOOL finished) { 349 | completeBlock(); 350 | }]; 351 | } else { 352 | [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{ 353 | animateBlock(); 354 | } completion:^(BOOL finished) { 355 | completeBlock(); 356 | }]; 357 | } 358 | } else { 359 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 360 | 361 | UIView *containerView = [transitionContext containerView]; 362 | [containerView addSubview:toVC.view]; 363 | 364 | // 动画block 365 | void(^animateBlock)() = ^{ 366 | toVC.view.frame = CGRectMake(0, 0, toVC.view.frame.size.width, toVC.view.frame.size.height); 367 | self.tapView.alpha = 0.f; 368 | }; 369 | 370 | // 动画完成block 371 | void(^completeBlock)() = ^{ 372 | if ([transitionContext transitionWasCancelled]) { 373 | [transitionContext completeTransition:NO]; 374 | } else { 375 | [transitionContext completeTransition:YES]; 376 | self.showLeft = NO; 377 | 378 | // 去除点击dismiss的View 379 | // [self.tapView removeFromSuperview]; 380 | } 381 | }; 382 | 383 | if (self.interactive) { 384 | // 呵呵🙃 385 | [UIView animateWithDuration:[self transitionDuration:transitionContext] delay:0 options:UIViewAnimationOptionCurveLinear animations:^{ 386 | animateBlock(); 387 | } completion:^(BOOL finished) { 388 | completeBlock(); 389 | }]; 390 | } else { 391 | [UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{ 392 | animateBlock(); 393 | } completion:^(BOOL finished) { 394 | completeBlock(); 395 | }]; 396 | } 397 | } 398 | } 399 | 400 | #pragma mark - KVO Methods 401 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 402 | if (![keyPath isEqualToString:@"state"]) { 403 | return; 404 | } 405 | 406 | UIGestureRecognizerState state = [change[@"new"] integerValue]; 407 | if (state == UIGestureRecognizerStateEnded 408 | || state == UIGestureRecognizerStateCancelled 409 | || state == UIGestureRecognizerStateFailed) { 410 | 411 | UINavigationController *naviVC = (__bridge UINavigationController *)(context); 412 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 413 | [self setGestureEnabled:naviVC.viewControllers.count == 1]; 414 | if (naviVC.viewControllers.count == 1) { 415 | UIScreenEdgePanGestureRecognizer *gesture = (UIScreenEdgePanGestureRecognizer *)object; 416 | // 关闭导航栏侧滑手势 417 | gesture.enabled = NO; 418 | // 去除手势观察者 419 | if (gesture.stateObserve) { 420 | [object removeObserver:self forKeyPath:keyPath]; 421 | [gesture setStateObserve:nil]; 422 | } 423 | } 424 | }); 425 | } 426 | } 427 | 428 | #pragma mark - setter/getter方法 429 | - (UIView *)tapView { 430 | if (!_tapView) { 431 | _tapView = [[UIView alloc] initWithFrame:self.coverVC.view.bounds]; 432 | _tapView.backgroundColor = [UIColor colorWithWhite:0 alpha:.2f]; 433 | _tapView.alpha = 0.f; 434 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissLeftView)]; 435 | [_tapView addGestureRecognizer:tapGesture]; 436 | } 437 | return _tapView; 438 | } 439 | 440 | - (UIPanGestureRecognizer *)panGesture { 441 | if (!_panGesture) { 442 | _panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)]; 443 | _panGesture.delegate = self; 444 | } 445 | return _panGesture; 446 | } 447 | 448 | @end 449 | 450 | /** 451 | 动态交换方法 452 | 453 | @param class 需要交换的类 454 | @param sourceSelector 原始方法 455 | @param customSelector 交换方法 456 | */ 457 | static inline void swizzlingInstanceMethods(Class class, SEL sourceSelector, SEL customSelector) { 458 | Method sourceMethod = class_getInstanceMethod(class, sourceSelector); 459 | Method customMethod = class_getInstanceMethod(class, customSelector); 460 | 461 | if (class_addMethod(class, sourceSelector, method_getImplementation(customMethod), method_getTypeEncoding(customMethod))) { 462 | class_replaceMethod(class, customSelector, method_getImplementation(sourceMethod), method_getTypeEncoding(sourceMethod)); 463 | } else { 464 | method_exchangeImplementations(sourceMethod, customMethod); 465 | } 466 | } 467 | 468 | @implementation UINavigationController (DYLM_Push) 469 | 470 | + (void)swizzlingPushAndPop { 471 | static dispatch_once_t onceToken; 472 | dispatch_once(&onceToken, ^{ 473 | swizzlingInstanceMethods(self, @selector(pushViewController:animated:), @selector(DYL_pushViewController:animated:)); 474 | swizzlingInstanceMethods(self, @selector(popViewControllerAnimated:), @selector(DYL_popViewControllerAnimated:)); 475 | swizzlingInstanceMethods(self, @selector(popToViewController:animated:), @selector(DYL_popToViewController:animated:)); 476 | swizzlingInstanceMethods(self, @selector(popToRootViewControllerAnimated:), @selector(DYL_popToRootViewControllerAnimated:)); 477 | swizzlingInstanceMethods(self, NSSelectorFromString(@"dealloc"), @selector(DYL_dealloc)); 478 | }); 479 | } 480 | 481 | - (BOOL)shouldRefreshDYLMGesture { 482 | return self.presentingViewController == nil; 483 | } 484 | 485 | - (void)refreshDYLMGestureEnabled { 486 | if ([self shouldRefreshDYLMGesture]) { 487 | [[DYLeftSlipManager sharedManager] setGestureEnabled:self.viewControllers.count == 1]; 488 | } 489 | } 490 | 491 | - (void)DYL_pushViewController:(UIViewController *)viewController animated:(BOOL)animated {\ 492 | [self DYL_pushViewController:viewController animated:animated]; 493 | // 判断是否需要刷新侧滑菜单的手势,在第一次被present出来的时候,self.presentingViewController为nil,此时必须依靠self.viewControllers.count进行判断是否是present出来 494 | if (![self shouldRefreshDYLMGesture] || self.viewControllers.count == 1) { 495 | return; 496 | } 497 | 498 | [self refreshDYLMGestureEnabled]; 499 | 500 | // 该navigationController的全屏滑动手势 501 | UIScreenEdgePanGestureRecognizer *interactivePopGestureRecognizer = (UIScreenEdgePanGestureRecognizer *)self.interactivePopGestureRecognizer; 502 | 503 | if (!interactivePopGestureRecognizer.stateObserve) { 504 | // 监听手势的状态 505 | [interactivePopGestureRecognizer addObserver:[DYLeftSlipManager sharedManager] forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:(__bridge void * _Nullable)(self)]; 506 | [interactivePopGestureRecognizer setStateObserve:[DYLeftSlipManager sharedManager]]; 507 | } 508 | 509 | if (self.viewControllers.count > 1) { 510 | // 开启导航栏手势交互 511 | interactivePopGestureRecognizer.enabled = YES; 512 | } 513 | /**********************************************************************************************/ 514 | // // 手势执行的target 515 | // id gestureRecognizerTarget = ((NSArray *)[interactivePopGestureRecognizer valueForKey:@"_targets"]).firstObject; 516 | // // 执行handleNavigationTransition:的私有对象 517 | // id navigationInteractiveTransition = [gestureRecognizerTarget valueForKeyPath:@"_target"]; 518 | // _target = navigationInteractiveTransition; 519 | /**********************************************************************************************/ 520 | } 521 | 522 | - (UIViewController *)DYL_popViewControllerAnimated:(BOOL)animated { 523 | UIViewController *viewController = [self DYL_popViewControllerAnimated:animated]; 524 | 525 | // 判断是否需要刷新侧滑菜单的手势 526 | if ([self shouldRefreshDYLMGesture]) { 527 | if (viewController) { 528 | [self refreshDYLMGestureEnabled]; 529 | } else { 530 | UIScreenEdgePanGestureRecognizer *interactivePopGestureRecognizer = (UIScreenEdgePanGestureRecognizer *)self.interactivePopGestureRecognizer; 531 | interactivePopGestureRecognizer.enabled = NO; 532 | } 533 | } 534 | 535 | return viewController; 536 | } 537 | 538 | - (NSArray<__kindof UIViewController *> *)DYL_popToViewController:(UIViewController *)viewController animated:(BOOL)animated { 539 | NSArray<__kindof UIViewController *> *vcArray = [self DYL_popToViewController:viewController animated:animated]; 540 | 541 | // 判断是否需要刷新侧滑菜单的手势 542 | if ([self shouldRefreshDYLMGesture]) { 543 | [self refreshDYLMGestureEnabled]; 544 | } 545 | 546 | return vcArray; 547 | } 548 | 549 | - (NSArray<__kindof UIViewController *> *)DYL_popToRootViewControllerAnimated:(BOOL)animated { 550 | NSArray<__kindof UIViewController *> *vcArray = [self DYL_popToRootViewControllerAnimated:animated]; 551 | // 判断是否需要刷新侧滑菜单的手势 552 | if ([self shouldRefreshDYLMGesture]) { 553 | [self refreshDYLMGestureEnabled]; 554 | } 555 | return vcArray; 556 | } 557 | 558 | - (void)DYL_dealloc { 559 | // 该navigationController的全屏滑动手势 560 | UIScreenEdgePanGestureRecognizer *interactivePopGestureRecognizer = (UIScreenEdgePanGestureRecognizer *)self.interactivePopGestureRecognizer; 561 | // 移除KVO监听 562 | if (interactivePopGestureRecognizer.stateObserve) { 563 | [interactivePopGestureRecognizer removeObserver:interactivePopGestureRecognizer.stateObserve forKeyPath:@"state"]; 564 | } 565 | 566 | [self DYL_dealloc]; 567 | } 568 | 569 | @end 570 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/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 | $(MARKETING_VERSION) 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 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 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/LeftTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // LeftTableViewController.h 3 | // DYLeftSlipManager 4 | // 这只是个左滑出来的VC,不管关心它内部的代码,完全解耦的 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LeftTableViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/LeftTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // LeftTableViewController.m 3 | // DYLeftSlipManager 4 | // 这只是个左滑出来的VC,不管关心它内部的代码,完全解耦的 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import "LeftTableViewController.h" 10 | #import "DYLeftSlipManager.h" 11 | 12 | @interface LeftTableViewController () 13 | 14 | @end 15 | 16 | @implementation LeftTableViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | self.view.backgroundColor = [UIColor brownColor]; 22 | [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"]; 23 | } 24 | 25 | #pragma mark - Table view data source 26 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 27 | return 10; 28 | } 29 | 30 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 31 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; 32 | 33 | cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row]; 34 | 35 | return cell; 36 | } 37 | 38 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 39 | [[DYLeftSlipManager sharedManager] dismissLeftView]; 40 | } 41 | 42 | - (void)dealloc { 43 | NSLog(@"%s",__func__); 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/TabbarController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TabbarController.h 3 | // DYLeftSlipManager 4 | // 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TabbarController : UITabBarController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/TabbarController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TabbarController.m 3 | // DYLeftSlipManager 4 | // 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import "TabbarController.h" 10 | #import "DYLeftSlipManager.h" 11 | #import "LeftTableViewController.h" 12 | 13 | @interface TabbarController () 14 | 15 | @end 16 | 17 | @implementation TabbarController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | self.view.layer.shadowOpacity = 1; 23 | self.view.layer.shadowColor = [UIColor colorWithWhite:0 alpha:1].CGColor; 24 | 25 | [[DYLeftSlipManager sharedManager] setLeftViewController:[LeftTableViewController new] coverViewController:self]; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DYLeftSlipManager 4 | // 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DYLeftSlipManager 4 | // 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BaseViewController.h" 11 | 12 | #import "DYLeftSlipManager.h" 13 | 14 | @interface ViewController () 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | 23 | self.navigationController.navigationBar.translucent = NO; 24 | } 25 | 26 | - (IBAction)click:(id)sender { 27 | // 代码唤出左滑视图 28 | [[DYLeftSlipManager sharedManager] showLeftView]; 29 | } 30 | 31 | - (IBAction)pushAction:(id)sender { 32 | // push下一个vc 33 | BaseViewController *vc = [[BaseViewController alloc] init]; 34 | vc.hidesBottomBarWhenPushed = YES; 35 | [self.navigationController pushViewController:vc animated:YES]; 36 | } 37 | 38 | - (IBAction)presentAction:(UIButton *)sender { 39 | 40 | BaseViewController *vc = [[BaseViewController alloc] init]; 41 | UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:vc]; 42 | [self presentViewController:naviVC animated:YES completion:^{ 43 | 44 | }]; 45 | } 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /DYLeftSlipManager/DYLeftSlipManager/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DYLeftSlipManager 4 | // 5 | // Created by daiyi on 2016/11/9. 6 | // Copyright © 2016年 DY. 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 | -------------------------------------------------------------------------------- /DYLeftSlipManagerGIF.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maybeisyi/DYLeftSlipManager/8c95745f14ee2daf9be3a2f2be60687848bb9e05/DYLeftSlipManagerGIF.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DYLeftSlipManager 2 | 3 | ### 一行代码实现侧滑。完全解耦,两个界面之间不需要有任何耦合。基于控制器自定义转场。 4 | 5 | 使用: 6 | 7 | 导入`#import "DYLeftSlipManager.h" ` 8 | 9 | ```iOS 10 | // 注意这个控制器是右滑视图控制器,由于完全解耦,所以在DYLeftSlipManager内部是对该控制器强引用防止销毁。 11 | 12 | LeftTableViewController *leftVC = [LeftTableViewController new]; 13 | 14 | [[DYLeftSlipManager sharedManager] setLeftViewController:leftVC coverViewController:self]; 15 | 16 | // 这个self是覆盖在右滑视图上层的控制器,一般应用中就是UITabBarController 17 | ``` 18 | 19 | 嗯哼。是完全解耦的,你可以在任意地方调用这两句代码即可。 20 | 21 | 具体请看代码(好像也没有具体的了)。 22 | 23 | 实现思路:http://daiyi.pro/2017/03/12/DYLeftSlipManager_analysis/ 24 | 25 | 相对于网上其他DEMO来说,本例是利用了控制器转场实现的,其他DEMO基本都是View上加侧滑View,这样的话两个界面之间耦合度太高,两个View都归一个C管,不能忍~~~本例就是两个控制器,各管各的业务。 26 | 27 | ![DYLeftSlipManagerGIF](DYLeftSlipManagerGIF.gif) 28 | --------------------------------------------------------------------------------