diff --git a/.gitignore b/.gitignore index 6cf1eee..05910f5 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ fastlane/screenshots iOSInjectionProject/ .DS_Store +Pods +*.xcworkspacedata +WBSBlog.xcworkspace/xcshareddata diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..8fa08ee --- /dev/null +++ b/Podfile @@ -0,0 +1,23 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' + +target 'WBSBlog' do + # Comment the next line if you don't want to use dynamic frameworks + use_frameworks! + + # Pods for WBSBlog + + pod 'MMDrawerController' + + + + target 'WBSBlogTests' do + inherit! :search_paths + # Pods for testing + end + + target 'WBSBlogUITests' do + # Pods for testing + end + +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000..0ac5cd7 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,27 @@ +PODS: + - MMDrawerController (0.6.0): + - MMDrawerController/Core (= 0.6.0) + - MMDrawerController/MMDrawerBarButtonItem (= 0.6.0) + - MMDrawerController/MMDrawerVisualStates (= 0.6.0) + - MMDrawerController/Subclass (= 0.6.0) + - MMDrawerController/Core (0.6.0) + - MMDrawerController/MMDrawerBarButtonItem (0.6.0): + - MMDrawerController/Core + - MMDrawerController/MMDrawerVisualStates (0.6.0): + - MMDrawerController/Core + - MMDrawerController/Subclass (0.6.0): + - MMDrawerController/Core + +DEPENDENCIES: + - MMDrawerController + +SPEC REPOS: + trunk: + - MMDrawerController + +SPEC CHECKSUMS: + MMDrawerController: e3a54a5570388463ad3b36975251575b50c4e1a0 + +PODFILE CHECKSUM: 23a22ec929a91e4e4ae0146540f464242fed7b1e + +COCOAPODS: 1.14.3 diff --git a/WBSBlog.xcodeproj/project.pbxproj b/WBSBlog.xcodeproj/project.pbxproj old mode 100755 new mode 100644 index e337eac..af695fb --- a/WBSBlog.xcodeproj/project.pbxproj +++ b/WBSBlog.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 1A9D5AEE7415F893038E4FAD /* Pods_WBSBlogTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB74F6493927E51CE9912774 /* Pods_WBSBlogTests.framework */; }; + 279AC64E50DCEFEEF18CB5BD /* Pods_WBSBlog.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 35216CFC29B528836F163404 /* Pods_WBSBlog.framework */; }; 4E3B10451E4868E2002EF825 /* navigationbar_sidebar.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E3B10441E4868E2002EF825 /* navigationbar_sidebar.png */; }; 4E3B10471E4868EA002EF825 /* navigationbar-search.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E3B10461E4868EA002EF825 /* navigationbar-search.png */; }; 4E3B104D1E4990D2002EF825 /* default_portrait@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E3B104B1E4990D2002EF825 /* default_portrait@2x.png */; }; @@ -79,10 +81,6 @@ 4EDFD7DB1E35A991006DD1E6 /* SVProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDFD7D51E35A991006DD1E6 /* SVProgressHUD.m */; }; 4EDFD7DC1E35A991006DD1E6 /* SVRadialGradientLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDFD7D71E35A991006DD1E6 /* SVRadialGradientLayer.m */; }; 4EDFD7F11E360463006DD1E6 /* UIWindow+KeyWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDFD7F01E360463006DD1E6 /* UIWindow+KeyWindow.m */; }; - 4EDFD8171E374642006DD1E6 /* MMDrawerBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDFD80F1E374642006DD1E6 /* MMDrawerBarButtonItem.m */; }; - 4EDFD8181E374642006DD1E6 /* MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDFD8121E374642006DD1E6 /* MMDrawerController.m */; }; - 4EDFD8191E374642006DD1E6 /* MMDrawerVisualState.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDFD8141E374642006DD1E6 /* MMDrawerVisualState.m */; }; - 4EDFD81A1E374642006DD1E6 /* UIViewController+MMDrawerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EDFD8161E374642006DD1E6 /* UIViewController+MMDrawerController.m */; }; 4EDFF3781E375508000C47D2 /* widget-original@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4EDFF2D51E375508000C47D2 /* widget-original@2x.png */; }; 4EDFF3791E375508000C47D2 /* widget-original@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4EDFF2D61E375508000C47D2 /* widget-original@3x.png */; }; 4EDFF37A1E375508000C47D2 /* widget_repost@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4EDFF2D71E375508000C47D2 /* widget_repost@2x.png */; }; @@ -566,6 +564,7 @@ 4EF788731E51A9D800DA058F /* WBSOldHomePostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EF788711E51A9D800DA058F /* WBSOldHomePostViewController.m */; }; 4EF788991E51BDC400DA058F /* WBSPostTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EF788981E51BDC400DA058F /* WBSPostTableView.m */; }; 4EF7889C1E51BF0100DA058F /* WBSBasePostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EF7889B1E51BF0100DA058F /* WBSBasePostViewController.m */; }; + EFEC670009DA8B0FC5E78A16 /* Pods_WBSBlog_WBSBlogUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3A18153B6D8DE9FEE2DD1D0 /* Pods_WBSBlog_WBSBlogUITests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -586,6 +585,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 05A52E00FD8F14942E4F4321 /* Pods-WBSBlog-WBSBlogUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WBSBlog-WBSBlogUITests.release.xcconfig"; path = "Target Support Files/Pods-WBSBlog-WBSBlogUITests/Pods-WBSBlog-WBSBlogUITests.release.xcconfig"; sourceTree = ""; }; + 2B094F9945C0BD3178FDFC5B /* Pods-WBSBlog.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WBSBlog.release.xcconfig"; path = "Target Support Files/Pods-WBSBlog/Pods-WBSBlog.release.xcconfig"; sourceTree = ""; }; + 35216CFC29B528836F163404 /* Pods_WBSBlog.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WBSBlog.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4E3B10441E4868E2002EF825 /* navigationbar_sidebar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = navigationbar_sidebar.png; sourceTree = ""; }; 4E3B10461E4868EA002EF825 /* navigationbar-search.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "navigationbar-search.png"; sourceTree = ""; }; 4E3B104B1E4990D2002EF825 /* default_portrait@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "default_portrait@2x.png"; sourceTree = ""; }; @@ -714,15 +716,6 @@ 4EDFD7D71E35A991006DD1E6 /* SVRadialGradientLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVRadialGradientLayer.m; sourceTree = ""; }; 4EDFD7EF1E360462006DD1E6 /* UIWindow+KeyWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIWindow+KeyWindow.h"; path = "WBSBlog/Utils/Catagory/UIWindow+KeyWindow.h"; sourceTree = SOURCE_ROOT; }; 4EDFD7F01E360463006DD1E6 /* UIWindow+KeyWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIWindow+KeyWindow.m"; path = "WBSBlog/Utils/Catagory/UIWindow+KeyWindow.m"; sourceTree = SOURCE_ROOT; }; - 4EDFD80E1E374642006DD1E6 /* MMDrawerBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerBarButtonItem.h; sourceTree = ""; }; - 4EDFD80F1E374642006DD1E6 /* MMDrawerBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerBarButtonItem.m; sourceTree = ""; }; - 4EDFD8101E374642006DD1E6 /* MMDrawerController+Subclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MMDrawerController+Subclass.h"; sourceTree = ""; }; - 4EDFD8111E374642006DD1E6 /* MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerController.h; sourceTree = ""; }; - 4EDFD8121E374642006DD1E6 /* MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerController.m; sourceTree = ""; }; - 4EDFD8131E374642006DD1E6 /* MMDrawerVisualState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMDrawerVisualState.h; sourceTree = ""; }; - 4EDFD8141E374642006DD1E6 /* MMDrawerVisualState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMDrawerVisualState.m; sourceTree = ""; }; - 4EDFD8151E374642006DD1E6 /* UIViewController+MMDrawerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+MMDrawerController.h"; sourceTree = ""; }; - 4EDFD8161E374642006DD1E6 /* UIViewController+MMDrawerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+MMDrawerController.m"; sourceTree = ""; }; 4EDFF2D51E375508000C47D2 /* widget-original@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "widget-original@2x.png"; sourceTree = ""; }; 4EDFF2D61E375508000C47D2 /* widget-original@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "widget-original@3x.png"; sourceTree = ""; }; 4EDFF2D71E375508000C47D2 /* widget_repost@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "widget_repost@2x.png"; sourceTree = ""; }; @@ -1514,6 +1507,12 @@ 4EF788981E51BDC400DA058F /* WBSPostTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBSPostTableView.m; sourceTree = ""; }; 4EF7889A1E51BF0100DA058F /* WBSBasePostViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBSBasePostViewController.h; sourceTree = ""; }; 4EF7889B1E51BF0100DA058F /* WBSBasePostViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBSBasePostViewController.m; sourceTree = ""; }; + 56DA46F9A50FA823A4338123 /* Pods-WBSBlog.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WBSBlog.debug.xcconfig"; path = "Target Support Files/Pods-WBSBlog/Pods-WBSBlog.debug.xcconfig"; sourceTree = ""; }; + 5AD3C10E69C28CB761990DA8 /* Pods-WBSBlogTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WBSBlogTests.debug.xcconfig"; path = "Target Support Files/Pods-WBSBlogTests/Pods-WBSBlogTests.debug.xcconfig"; sourceTree = ""; }; + 8A0BDA3D2F5A5D70280732FF /* Pods-WBSBlog-WBSBlogUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WBSBlog-WBSBlogUITests.debug.xcconfig"; path = "Target Support Files/Pods-WBSBlog-WBSBlogUITests/Pods-WBSBlog-WBSBlogUITests.debug.xcconfig"; sourceTree = ""; }; + B3A18153B6D8DE9FEE2DD1D0 /* Pods_WBSBlog_WBSBlogUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WBSBlog_WBSBlogUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DB74F6493927E51CE9912774 /* Pods_WBSBlogTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_WBSBlogTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + FCA9F0CE9737D28EA0AE54B8 /* Pods-WBSBlogTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WBSBlogTests.release.xcconfig"; path = "Target Support Files/Pods-WBSBlogTests/Pods-WBSBlogTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1523,6 +1522,7 @@ files = ( 4EDFD7A91E349BB6006DD1E6 /* libsqlite3.0.tbd in Frameworks */, 4EF38F691D42FBD200CE28A4 /* libiconv.tbd in Frameworks */, + 279AC64E50DCEFEEF18CB5BD /* Pods_WBSBlog.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1530,6 +1530,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 1A9D5AEE7415F893038E4FAD /* Pods_WBSBlogTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1537,12 +1538,26 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + EFEC670009DA8B0FC5E78A16 /* Pods_WBSBlog_WBSBlogUITests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 3FFEC6B855391D365D5F74A5 /* Pods */ = { + isa = PBXGroup; + children = ( + 56DA46F9A50FA823A4338123 /* Pods-WBSBlog.debug.xcconfig */, + 2B094F9945C0BD3178FDFC5B /* Pods-WBSBlog.release.xcconfig */, + 8A0BDA3D2F5A5D70280732FF /* Pods-WBSBlog-WBSBlogUITests.debug.xcconfig */, + 05A52E00FD8F14942E4F4321 /* Pods-WBSBlog-WBSBlogUITests.release.xcconfig */, + 5AD3C10E69C28CB761990DA8 /* Pods-WBSBlogTests.debug.xcconfig */, + FCA9F0CE9737D28EA0AE54B8 /* Pods-WBSBlogTests.release.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; 4E3B10711E4AC9EF002EF825 /* WPXMLRPC */ = { isa = PBXGroup; children = ( @@ -1675,6 +1690,9 @@ isa = PBXGroup; children = ( 4EDFD7A81E349BB6006DD1E6 /* libsqlite3.0.tbd */, + 35216CFC29B528836F163404 /* Pods_WBSBlog.framework */, + B3A18153B6D8DE9FEE2DD1D0 /* Pods_WBSBlog_WBSBlogUITests.framework */, + DB74F6493927E51CE9912774 /* Pods_WBSBlogTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -1695,22 +1713,6 @@ path = SVProgressHUD; sourceTree = ""; }; - 4EDFD80D1E374642006DD1E6 /* MMDrawerController */ = { - isa = PBXGroup; - children = ( - 4EDFD80E1E374642006DD1E6 /* MMDrawerBarButtonItem.h */, - 4EDFD80F1E374642006DD1E6 /* MMDrawerBarButtonItem.m */, - 4EDFD8101E374642006DD1E6 /* MMDrawerController+Subclass.h */, - 4EDFD8111E374642006DD1E6 /* MMDrawerController.h */, - 4EDFD8121E374642006DD1E6 /* MMDrawerController.m */, - 4EDFD8131E374642006DD1E6 /* MMDrawerVisualState.h */, - 4EDFD8141E374642006DD1E6 /* MMDrawerVisualState.m */, - 4EDFD8151E374642006DD1E6 /* UIViewController+MMDrawerController.h */, - 4EDFD8161E374642006DD1E6 /* UIViewController+MMDrawerController.m */, - ); - path = MMDrawerController; - sourceTree = ""; - }; 4EDFF2D31E375508000C47D2 /* Images_图片/网页 */ = { isa = PBXGroup; children = ( @@ -2109,6 +2111,7 @@ 4EF149F51D3DF61D00D28265 /* WBSBlogUITests */, 4EF149CF1D3DF61D00D28265 /* Products */, 4EDFD7A71E349BB5006DD1E6 /* Frameworks */, + 3FFEC6B855391D365D5F74A5 /* Pods */, ); sourceTree = ""; usesTabs = 0; @@ -2180,7 +2183,6 @@ 4EDFD78C1E348E98006DD1E6 /* FMDB */, 4EF14D191D3E32F600D28265 /* GHMarkdownParser */, 4EF14D671D3E32F600D28265 /* Reachability */, - 4EDFD80D1E374642006DD1E6 /* MMDrawerController */, 4EF14D761D3E32F600D28265 /* SDWebImage */, 4EF14D971D3E32F600D28265 /* GPUImage */, 4EF7881F1E51609500DA058F /* MJRefresh */, @@ -3267,9 +3269,11 @@ isa = PBXNativeTarget; buildConfigurationList = 4EF149FB1D3DF61D00D28265 /* Build configuration list for PBXNativeTarget "WBSBlog" */; buildPhases = ( + BA8933E2276DED280309710F /* [CP] Check Pods Manifest.lock */, 4EF149CA1D3DF61D00D28265 /* Sources */, 4EF149CB1D3DF61D00D28265 /* Frameworks */, 4EF149CC1D3DF61D00D28265 /* Resources */, + F802B47B873E969A8CC767C4 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -3284,6 +3288,7 @@ isa = PBXNativeTarget; buildConfigurationList = 4EF149FE1D3DF61D00D28265 /* Build configuration list for PBXNativeTarget "WBSBlogTests" */; buildPhases = ( + 184C7D9FF747B86B0E5E7295 /* [CP] Check Pods Manifest.lock */, 4EF149E31D3DF61D00D28265 /* Sources */, 4EF149E41D3DF61D00D28265 /* Frameworks */, 4EF149E51D3DF61D00D28265 /* Resources */, @@ -3302,9 +3307,11 @@ isa = PBXNativeTarget; buildConfigurationList = 4EF14A011D3DF61D00D28265 /* Build configuration list for PBXNativeTarget "WBSBlogUITests" */; buildPhases = ( + 0E6F5E3FE2E501B88D7AA516 /* [CP] Check Pods Manifest.lock */, 4EF149EE1D3DF61D00D28265 /* Sources */, 4EF149EF1D3DF61D00D28265 /* Frameworks */, 4EF149F01D3DF61D00D28265 /* Resources */, + 91A27601EA5BA2D9B3907D24 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -3328,7 +3335,7 @@ TargetAttributes = { 4EF149CD1D3DF61D00D28265 = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = 6XB2PBHRRB; + DevelopmentTeam = S37Y3YKZVB; LastSwiftMigration = 0820; ProvisioningStyle = Automatic; }; @@ -3347,6 +3354,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -3566,6 +3574,111 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 0E6F5E3FE2E501B88D7AA516 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-WBSBlog-WBSBlogUITests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 184C7D9FF747B86B0E5E7295 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-WBSBlogTests-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 91A27601EA5BA2D9B3907D24 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-WBSBlog-WBSBlogUITests/Pods-WBSBlog-WBSBlogUITests-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/MMDrawerController/MMDrawerController.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MMDrawerController.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-WBSBlog-WBSBlogUITests/Pods-WBSBlog-WBSBlogUITests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + BA8933E2276DED280309710F /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-WBSBlog-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + F802B47B873E969A8CC767C4 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-WBSBlog/Pods-WBSBlog-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/MMDrawerController/MMDrawerController.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MMDrawerController.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-WBSBlog/Pods-WBSBlog-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 4EF149CA1D3DF61D00D28265 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -3642,7 +3755,6 @@ 4EF14F8C1D3E32F700D28265 /* GPUImageLaplacianFilter.m in Sources */, 4EF14FBF1D3E32F700D28265 /* GPUImageShiTomasiFeatureDetectionFilter.m in Sources */, 4EF0E88E1E4CBF9600580F09 /* UIRefreshControl+AFNetworking.m in Sources */, - 4EDFD8181E374642006DD1E6 /* MMDrawerController.m in Sources */, 4EF14FC91D3E32F700D28265 /* GPUImageStillCamera.m in Sources */, 4EF14F4F1D3E32F700D28265 /* GPUImageBoxBlurFilter.m in Sources */, 4EF14F901D3E32F700D28265 /* GPUImageLineGenerator.m in Sources */, @@ -3756,7 +3868,6 @@ 4ED5A7AE1E4B2761005ADE05 /* WordPressApi.m in Sources */, 4EF14FCD1D3E32F700D28265 /* GPUImageTextureInput.m in Sources */, 4EDFD7881E348C5D006DD1E6 /* NetworkingCenter.m in Sources */, - 4EDFD81A1E374642006DD1E6 /* UIViewController+MMDrawerController.m in Sources */, 4EF14FD81D3E32F700D28265 /* GPUImageTwoInputFilter.m in Sources */, 4EF7886D1E51A9A500DA058F /* WBSHomePostViewController.m in Sources */, 4EF787EC1E51517E00DA058F /* WBSPostDetailViewController.m in Sources */, @@ -3787,7 +3898,6 @@ 4EF787F11E51517E00DA058F /* WBSPostCell.m in Sources */, 4EF14F511D3E32F700D28265 /* GPUImageBuffer.m in Sources */, 4EF14F0D1D3E32F700D28265 /* xml.c in Sources */, - 4EDFD8191E374642006DD1E6 /* MMDrawerVisualState.m in Sources */, 4EB5D7841E56E7D500401F2F /* WBSEmojiPanelVC.m in Sources */, 4EF14F3F1D3E32F700D28265 /* UIView+WebCacheOperation.m in Sources */, 4EF14FA61D3E32F700D28265 /* GPUImageOpeningFilter.m in Sources */, @@ -3921,7 +4031,6 @@ 4EF14FC01D3E32F700D28265 /* GPUImageSingleComponentGaussianBlurFilter.m in Sources */, 4EF14FB41D3E32F700D28265 /* GPUImageRawDataOutput.m in Sources */, 4EF14EFF1D3E32F700D28265 /* amalloc.c in Sources */, - 4EDFD8171E374642006DD1E6 /* MMDrawerBarButtonItem.m in Sources */, 4EF0E88D1E4CBF9600580F09 /* UIProgressView+AFNetworking.m in Sources */, 4EF14F9A1D3E32F700D28265 /* GPUImageMissEtikateFilter.m in Sources */, 4EF14FE61D3E32F700D28265 /* GPUImagePicture+TextureSubimage.m in Sources */, @@ -4067,20 +4176,21 @@ }; 4EF149FC1D3DF61D00D28265 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 56DA46F9A50FA823A4338123 /* Pods-WBSBlog.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 6XB2PBHRRB; + DEVELOPMENT_TEAM = S37Y3YKZVB; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/WBSBlog/Lib", ); GCC_PREFIX_HEADER = "$(SRCROOT)/WBSBlog/Others/WBSPrefixHeader.pch"; INFOPLIST_FILE = WBSBlog/WBSBlogInfo.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -4097,20 +4207,21 @@ }; 4EF149FD1D3DF61D00D28265 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 2B094F9945C0BD3178FDFC5B /* Pods-WBSBlog.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DEVELOPMENT_TEAM = 6XB2PBHRRB; + DEVELOPMENT_TEAM = S37Y3YKZVB; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/WBSBlog/Lib", ); GCC_PREFIX_HEADER = "$(SRCROOT)/WBSBlog/Others/WBSPrefixHeader.pch"; INFOPLIST_FILE = WBSBlog/WBSBlogInfo.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LIBRARY_SEARCH_PATHS = ( "$(inherited)", @@ -4128,6 +4239,7 @@ }; 4EF149FF1D3DF61D00D28265 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5AD3C10E69C28CB761990DA8 /* Pods-WBSBlogTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; INFOPLIST_FILE = WBSBlogTests/Info.plist; @@ -4140,6 +4252,7 @@ }; 4EF14A001D3DF61D00D28265 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = FCA9F0CE9737D28EA0AE54B8 /* Pods-WBSBlogTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; INFOPLIST_FILE = WBSBlogTests/Info.plist; @@ -4152,6 +4265,7 @@ }; 4EF14A021D3DF61D00D28265 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 8A0BDA3D2F5A5D70280732FF /* Pods-WBSBlog-WBSBlogUITests.debug.xcconfig */; buildSettings = { GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = WBSBlogUITests/Info.plist; @@ -4164,6 +4278,7 @@ }; 4EF14A031D3DF61D00D28265 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 05A52E00FD8F14942E4F4321 /* Pods-WBSBlog-WBSBlogUITests.release.xcconfig */; buildSettings = { GCC_PREFIX_HEADER = ""; INFOPLIST_FILE = WBSBlogUITests/Info.plist; diff --git a/WBSBlog/Lib/MMDrawerController/MMDrawerBarButtonItem.h b/WBSBlog/Lib/MMDrawerController/MMDrawerBarButtonItem.h deleted file mode 100755 index f0ee364..0000000 --- a/WBSBlog/Lib/MMDrawerController/MMDrawerBarButtonItem.h +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -/** - `MMDrawerBarButtonItem` provides convenience methods to create `UIBarButtonItems` with a default hamburger-menu asset. - */ - -@interface MMDrawerBarButtonItem : UIBarButtonItem - -///--------------------------------------- -/// @name Initializing a `MMDrawerBarButtonItem` -///--------------------------------------- - -/** - Creates and initializes an `MMDrawerBarButtonItem` without a border. - - @param target The target to forward the `action` to when the button is pressed. - @param action The action to call when the button is pressed. - - @return The newly-initialized bar button item. - */ --(instancetype)initWithTarget:(id)target action:(SEL)action; - -/** - Returns the current color of the menu button for the state requested. This property is deprecated in iOS 7.0. Use `tintColor` instead. - - @param state The UIControl state that the color is being requested for. - - @return The menu button color for the requested state. - */ --(UIColor *)menuButtonColorForState:(UIControlState)state __attribute__((deprecated("Use tintColor instead"))); - -/** - Sets the color of the menu button for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. Use `tintColor` instead. - - @param color The color to set. - @param state The state to set the color for. - */ --(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Use tintColor instead"))); - -/** - Returns the current color of the shadow for the state requested. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow. - - @param state The UIControl state that the color is being requested for. - - @return The menu button color for the requested state. - */ --(UIColor *)shadowColorForState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported"))); - -/** - Sets the color of the shadow for the specified state. For this control, only set colors for `UIControlStateNormal` and `UIControlStateHighlighted`. This property is deprecated in iOS 7.0. The menu button no longer supports a shadow. - - @param color The color to set. - @param state The state to set the color for. - */ --(void)setShadowColor:(UIColor *)color forState:(UIControlState)state __attribute__((deprecated("Shadow is no longer supported"))); - -@end diff --git a/WBSBlog/Lib/MMDrawerController/MMDrawerBarButtonItem.m b/WBSBlog/Lib/MMDrawerController/MMDrawerBarButtonItem.m deleted file mode 100755 index d29609c..0000000 --- a/WBSBlog/Lib/MMDrawerController/MMDrawerBarButtonItem.m +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#import "MMDrawerBarButtonItem.h" - -@interface MMDrawerMenuButtonView : UIButton -@property (nonatomic,strong) UIColor * menuButtonNormalColor; -@property (nonatomic,strong) UIColor * menuButtonHighlightedColor; - -@property (nonatomic,strong) UIColor * shadowNormalColor; -@property (nonatomic,strong) UIColor * shadowHighlightedColor; - --(UIColor *)menuButtonColorForState:(UIControlState)state; --(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state; - --(UIColor *)shadowColorForState:(UIControlState)state; --(void)setShadowColor:(UIColor *)color forState:(UIControlState)state; - -@end - -@implementation MMDrawerMenuButtonView - --(instancetype)initWithFrame:(CGRect)frame{ - self = [super initWithFrame:frame]; - if(self){ - [self setMenuButtonNormalColor:[[UIColor whiteColor] colorWithAlphaComponent:0.9f]]; - [self setMenuButtonHighlightedColor:[UIColor colorWithRed:139.0/255.0 - green:135.0/255.0 - blue:136.0/255.0 - alpha:0.9f]]; - - [self setShadowNormalColor:[[UIColor blackColor] colorWithAlphaComponent:0.5f]]; - [self setShadowHighlightedColor:[[UIColor blackColor] colorWithAlphaComponent:0.2f]]; - } - return self; -} - --(UIColor *)menuButtonColorForState:(UIControlState)state{ - UIColor * color; - switch (state) { - case UIControlStateNormal: - color = self.menuButtonNormalColor; - break; - case UIControlStateHighlighted: - color = self.menuButtonHighlightedColor; - break; - default: - break; - } - return color; -} - --(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{ - switch (state) { - case UIControlStateNormal: - [self setMenuButtonNormalColor:color]; - break; - case UIControlStateHighlighted: - [self setMenuButtonHighlightedColor:color]; - break; - default: - break; - } - [self setNeedsDisplay]; -} - --(UIColor *)shadowColorForState:(UIControlState)state{ - UIColor * color; - switch (state) { - case UIControlStateNormal: - color = self.shadowNormalColor; - break; - case UIControlStateHighlighted: - color = self.shadowHighlightedColor; - break; - default: - break; - } - return color; -} - --(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{ - switch (state) { - case UIControlStateNormal: - [self setShadowNormalColor:color]; - break; - case UIControlStateHighlighted: - [self setShadowHighlightedColor:color]; - break; - default: - break; - } - [self setNeedsDisplay]; -} - --(void)drawRect:(CGRect)rect{ - //// General Declarations - CGContextRef context = UIGraphicsGetCurrentContext(); - - //Sizes - CGFloat buttonWidth = CGRectGetWidth(self.bounds)*.80; - CGFloat buttonHeight = CGRectGetHeight(self.bounds)*.16; - CGFloat xOffset = CGRectGetWidth(self.bounds)*.10; - CGFloat yOffset = CGRectGetHeight(self.bounds)*.12; - CGFloat cornerRadius = 1.0; - - //// Color Declarations - UIColor* buttonColor = [self menuButtonColorForState:self.state]; - UIColor* shadowColor = [self shadowColorForState:self.state]; - - - //// Shadow Declarations - UIColor* shadow = shadowColor; - CGSize shadowOffset = CGSizeMake(0.0, 1.0); - CGFloat shadowBlurRadius = 0; - - //// Top Bun Drawing - UIBezierPath* topBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; - CGContextSaveGState(context); - CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); - [buttonColor setFill]; - [topBunPath fill]; - CGContextRestoreGState(context); - - //// Meat Drawing - UIBezierPath* meatPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*2 + buttonHeight, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; - CGContextSaveGState(context); - CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); - [buttonColor setFill]; - [meatPath fill]; - CGContextRestoreGState(context); - - //// Bottom Bun Drawing - UIBezierPath* bottomBunPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(xOffset, yOffset*3 + buttonHeight*2, buttonWidth, buttonHeight) cornerRadius:cornerRadius]; - CGContextSaveGState(context); - CGContextSetShadowWithColor(context, shadowOffset, shadowBlurRadius, shadow.CGColor); - [buttonColor setFill]; - [bottomBunPath fill]; - CGContextRestoreGState(context); -} - --(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ - [super touchesBegan:touches withEvent:event]; - [self setNeedsDisplay]; -} - --(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ - [super touchesEnded:touches withEvent:event]; - [self setNeedsDisplay]; -} - --(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{ - [super touchesCancelled:touches withEvent:event]; - [self setNeedsDisplay]; -} - --(void)setSelected:(BOOL)selected{ - [super setSelected:selected]; - [self setNeedsDisplay]; -} - --(void)setHighlighted:(BOOL)highlighted{ - [super setHighlighted:highlighted]; - [self setNeedsDisplay]; -} - --(void)setTintColor:(UIColor *)tintColor{ - if([super respondsToSelector:@selector(setTintColor:)]){ - [super setTintColor:tintColor]; - } -} - --(void)tintColorDidChange{ - [self setNeedsDisplay]; -} - -@end - -@interface MMDrawerBarButtonItem () -@property (nonatomic,strong) MMDrawerMenuButtonView * buttonView; - -@end - -@implementation MMDrawerBarButtonItem - -+(UIImage*)drawerButtonItemImage{ - - static UIImage *drawerButtonImage = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - - UIGraphicsBeginImageContextWithOptions( CGSizeMake(26, 26), NO, 0 ); - - //// Color Declarations - UIColor* fillColor = [UIColor whiteColor]; - - //// Frames - CGRect frame = CGRectMake(0, 0, 26, 26); - - //// Bottom Bar Drawing - UIBezierPath* bottomBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.72000 + 0.5), 16, 1)]; - [fillColor setFill]; - [bottomBarPath fill]; - - - //// Middle Bar Drawing - UIBezierPath* middleBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.48000 + 0.5), 16, 1)]; - [fillColor setFill]; - [middleBarPath fill]; - - - //// Top Bar Drawing - UIBezierPath* topBarPath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame) + floor((CGRectGetWidth(frame) - 16) * 0.50000 + 0.5), CGRectGetMinY(frame) + floor((CGRectGetHeight(frame) - 1) * 0.24000 + 0.5), 16, 1)]; - [fillColor setFill]; - [topBarPath fill]; - - drawerButtonImage = UIGraphicsGetImageFromCurrentImageContext(); - }); - - return drawerButtonImage; -} - --(instancetype)initWithTarget:(id)target action:(SEL)action{ - - if((floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)){ - return [self initWithImage:[self.class drawerButtonItemImage] - style:UIBarButtonItemStylePlain - target:target - action:action]; - } - else { - MMDrawerMenuButtonView * buttonView = [[MMDrawerMenuButtonView alloc] initWithFrame:CGRectMake(0, 0, 26, 26)]; - [buttonView addTarget:self action:@selector(touchUpInside:) forControlEvents:UIControlEventTouchUpInside]; - self = [self initWithCustomView:buttonView]; - if(self){ - [self setButtonView:buttonView]; - } - self.action = action; - self.target = target; - return self; - } -} - --(instancetype)initWithCoder:(NSCoder *)aDecoder{ - // non-ideal way to get the target/action, but it works - UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCoder: aDecoder]; - return [self initWithTarget:barButtonItem.target action:barButtonItem.action]; -} - --(void)touchUpInside:(id)sender{ - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" - [self.target performSelector:self.action withObject:sender]; -#pragma clang diagnostic pop; - -} - --(UIColor *)menuButtonColorForState:(UIControlState)state{ - return [self.buttonView menuButtonColorForState:state]; -} - --(void)setMenuButtonColor:(UIColor *)color forState:(UIControlState)state{ - [self.buttonView setMenuButtonColor:color forState:state]; -} - --(UIColor *)shadowColorForState:(UIControlState)state{ - return [self.buttonView shadowColorForState:state]; -} - --(void)setShadowColor:(UIColor *)color forState:(UIControlState)state{ - [self.buttonView setShadowColor:color forState:state]; -} - --(void)setTintColor:(UIColor *)tintColor{ - if([super respondsToSelector:@selector(setTintColor:)]){ - [super setTintColor:tintColor]; - } - if([self.buttonView respondsToSelector:@selector(setTintColor:)]){ - [self.buttonView setTintColor:tintColor]; - } -} - -@end diff --git a/WBSBlog/Lib/MMDrawerController/MMDrawerController+Subclass.h b/WBSBlog/Lib/MMDrawerController/MMDrawerController+Subclass.h deleted file mode 100755 index 419ff68..0000000 --- a/WBSBlog/Lib/MMDrawerController/MMDrawerController+Subclass.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import "MMDrawerController.h" - -/** - This class extension is designed for use by subclasses of `MMDrawerController` to customize the functionality to support a specific use-case by a developer. When importing this file, there is no need to also call `#import MMDrawerController.h`. - - None of these methods are meant to be called by non-subclasses of `MMDrawerController`. - */ - -@interface MMDrawerController (Subclass) -///--------------------------------------- -/// @name Gesture Interaction -///--------------------------------------- -/** - `MMDrawerController`'s single-tap gesture recognizer callback. This method is called every time the `UITapGestureRecognizer` is triggered. - - @param tapGesture The single-tap gesture recognizer instance that triggered the callback - */ --(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture __attribute((objc_requires_super)); - -/** - `MMDrawerController`'s pan gesture recognizer callback. This method is called every time the `UIPanGestureRecognizer` is updated. - - @warning This method do the minimal amount of work to keep the pan gesture responsive. - - @param panGesture The pan gesture recognizer instance that triggered the callback - */ --(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture __attribute((objc_requires_super)); - -/** - A `UIGestureRecognizerDelegate` method that is queried by `MMDrawerController`'s gestures to determine if it should receive the touch. - - @param gestureRecognizer The gesture recognizer that is asking if it should recieve a touch - @param touch The touch in question in gestureRecognizer.view's coordinate space - */ --(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch __attribute((objc_requires_super)); - -///--------------------------------------- -/// @name Drawer Presentation -///--------------------------------------- -/** - Sets the initial conditions for `MMDrawerController` and its child view controllers to prepare the drawer for a transition. If a drawer is open and the opposite drawer is being presented, it prepares that drawer to be hidden and vice-versa for the closing drawer. - - @param drawer The drawer side that will be presented - @param animated A boolean that indicates whether the presentation is being animated or not - */ --(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated __attribute((objc_requires_super)); - -///--------------------------------------- -/// @name Opening/Closing Drawer -///--------------------------------------- -/** - The method that handles closing the drawer. You can subclass this method to get a callback every time the drawer is about to be closed. You can inspect the current open side to determine what side is about to be closed. - - @param animated A boolean that indicates whether the drawer should close with animation - @param velocity A float indicating how fast the drawer should close - @param animationOptions A mask defining the animation options of the animation - @param completion A completion block to be called when the drawer is finished closing - */ --(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super)); - -/** - The method that handles opening the drawer. You can subclass this method to get a callback every time the drawer is about to be opened. - - @param drawerSide The drawer side that will be opened - @param animated A boolean that indicates whether the drawer should open with animation - @param velocity A float indicating how fast the drawer should open - @param animationOptions A mask defining the animation options of the animation - @param completion A completion block to be called when the drawer is finished opening - */ --(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion __attribute((objc_requires_super)); - -///--------------------------------------- -/// @name `UIViewController` Subclass Methods -///--------------------------------------- -/** - Included here to ensure subclasses call `super`. - - @param toInterfaceOrientation The interface orientation that the interface is moving to - @param duration The duration of the interface orientation animation - */ --(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super)); - -/** - Included here to ensure subclasses call `super`. - - @param toInterfaceOrientation The interface orientation that the interface is moving to - @param duration The duration of the interface orientation animation - */ --(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __attribute((objc_requires_super)); - -@end diff --git a/WBSBlog/Lib/MMDrawerController/MMDrawerController.h b/WBSBlog/Lib/MMDrawerController/MMDrawerController.h deleted file mode 100755 index 92833a6..0000000 --- a/WBSBlog/Lib/MMDrawerController/MMDrawerController.h +++ /dev/null @@ -1,455 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#import - -/** - `MMDrawerController` is a side drawer navigation container view controller designed to support the growing number of applications that leverage the side drawer paradigm. This library is designed to exclusively support side drawer navigation in light-weight, focused approach. - - ## Creating a MMDrawerController - `MMDrawerController` is a container view controller, similiar to `UINavigationController` or `UITabBarController`, with up to three child view controllers - Center, LeftDrawer, and RightDrawer. To create a `MMDrawerController`, you must first instantiate the drawer view controllers and the initial center controller, then call one of the init methods listed in this class. - - ## Handling a UINavigationController as the centerViewController - `MMDrawerController` automatically supports handling a `UINavigationController` as the `centerViewController`, and will correctly handle the proper gestures on each view (the navigation bar view as well as the content view for the visible view controller). Note that while this library does support other container view controllers, the open/close gestures are not customized to support them. - - ## Accessing MMDrawerController from the Child View Controller - You can leverage the category class (UIViewController+MMDrawerController) included with this library to access information about the parent `MMDrawerController`. Note that if you are contained within a UINavigationController, the `drawerContainerViewController` will still return the proper reference to the `drawerContainerViewController` parent, even though it is not the direct parent. Refer to the documentation included with the category for more information. - - ## How MMDrawerOpenCenterInteractionMode is handled - `MMDrawerOpenCenterInteractionMode` controls how the user should be able to interact with the center view controller when either drawer is open. By default, this is set to `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, which allows the user to interact with UINavigationBarItems while either drawer is open (typicaly used to click the menu button to close). If you set the interaction mode to `MMDrawerOpenCenterInteractionModeNone`, no items within the center view will be able to be interacted with while a drawer is open. Note that this setting has no effect at all on the `MMCloseDrawerGestureMode`. - - ## How Open/Close Gestures are handled - Two gestures are added to every instance of a drawer controller, one for pan and one for touch. `MMDrawerController` is the delegate for each of the gesture recoginzers, and determines if a touch should be sent to the appropriate gesture when a touch is detected compared with the masks set for open and close gestures and the state of the drawer controller. - - ## Integrating with State Restoration - In order to opt in to state restoration for `MMDrawerController`, you must set the `restorationIdentifier` of your drawer controller. Instances of your centerViewController, leftDrawerViewController and rightDrawerViewController must also be configured with their own `restorationIdentifier` (and optionally a restorationClass) if you intend for those to be restored as well. If your MMDrawerController had an open drawer when your app was sent to the background, that state will also be restored. - - ## What this library doesn't do. - This library is not meant for: - - Top or bottom drawer views - - Displaying both drawers at one time - - Displaying a minimum drawer width - - Support container view controllers other than `UINavigationController` as the center view controller. - */ - -typedef NS_ENUM(NSInteger,MMDrawerSide){ - MMDrawerSideNone = 0, - MMDrawerSideLeft, - MMDrawerSideRight, -}; - -typedef NS_OPTIONS(NSInteger, MMOpenDrawerGestureMode) { - MMOpenDrawerGestureModeNone = 0, - MMOpenDrawerGestureModePanningNavigationBar = 1 << 1, - MMOpenDrawerGestureModePanningCenterView = 1 << 2, - MMOpenDrawerGestureModeBezelPanningCenterView = 1 << 3, - MMOpenDrawerGestureModeCustom = 1 << 4, - MMOpenDrawerGestureModeAll = MMOpenDrawerGestureModePanningNavigationBar | - MMOpenDrawerGestureModePanningCenterView | - MMOpenDrawerGestureModeBezelPanningCenterView | - MMOpenDrawerGestureModeCustom, -}; - -typedef NS_OPTIONS(NSInteger, MMCloseDrawerGestureMode) { - MMCloseDrawerGestureModeNone = 0, - MMCloseDrawerGestureModePanningNavigationBar = 1 << 1, - MMCloseDrawerGestureModePanningCenterView = 1 << 2, - MMCloseDrawerGestureModeBezelPanningCenterView = 1 << 3, - MMCloseDrawerGestureModeTapNavigationBar = 1 << 4, - MMCloseDrawerGestureModeTapCenterView = 1 << 5, - MMCloseDrawerGestureModePanningDrawerView = 1 << 6, - MMCloseDrawerGestureModeCustom = 1 << 7, - MMCloseDrawerGestureModeAll = MMCloseDrawerGestureModePanningNavigationBar | - MMCloseDrawerGestureModePanningCenterView | - MMCloseDrawerGestureModeBezelPanningCenterView | - MMCloseDrawerGestureModeTapNavigationBar | - MMCloseDrawerGestureModeTapCenterView | - MMCloseDrawerGestureModePanningDrawerView | - MMCloseDrawerGestureModeCustom, -}; - -typedef NS_ENUM(NSInteger, MMDrawerOpenCenterInteractionMode) { - MMDrawerOpenCenterInteractionModeNone, - MMDrawerOpenCenterInteractionModeFull, - MMDrawerOpenCenterInteractionModeNavigationBarOnly, -}; - -@class MMDrawerController; -typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible); - -@interface MMDrawerController : UIViewController - -///--------------------------------------- -/// @name Accessing Drawer Container View Controller Properties -///--------------------------------------- - -/** - The center view controller. - - This can only be set via the init methods, as well as the `setNewCenterViewController:...` methods. The size of this view controller will automatically be set to the size of the drawer container view controller, and it's position is modified from within this class. Do not modify the frame externally. - */ -@property (nonatomic, strong) UIViewController * centerViewController; - -/** - The left drawer view controller. - - The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumLeftDrawerWidth`. Do not modify the frame externally. - */ -@property (nonatomic, strong) UIViewController * leftDrawerViewController; - -/** - The right drawer view controller. - - The size of this view controller is managed within this class, and is automatically set to the appropriate size based on the `maximumRightDrawerWidth`. Do not modify the frame externally. - */ -@property (nonatomic, strong) UIViewController * rightDrawerViewController; - -/** - The maximum width of the `leftDrawerViewController`. - - By default, this is set to 280. If the `leftDrawerViewController` is nil, this property will return 0.0; - */ -@property (nonatomic, assign) CGFloat maximumLeftDrawerWidth; - -/** - The maximum width of the `rightDrawerViewController`. - - By default, this is set to 280. If the `rightDrawerViewController` is nil, this property will return 0.0; - - */ -@property (nonatomic, assign) CGFloat maximumRightDrawerWidth; - -/** - The visible width of the `leftDrawerViewController`. - - Note this value can be greater than `maximumLeftDrawerWidth` during the full close animation when setting a new center view controller; - */ -@property (nonatomic, assign, readonly) CGFloat visibleLeftDrawerWidth; - -/** - The visible width of the `rightDrawerViewController`. - - Note this value can be greater than `maximumRightDrawerWidth` during the full close animation when setting a new center view controller; - */ -@property (nonatomic, assign, readonly) CGFloat visibleRightDrawerWidth; - -/** - The animation velocity of the open and close methods, measured in points per second. - - By default, this is set to 840 points per second (three times the default drawer width), meaning it takes 1/3 of a second for the `centerViewController` to open/close across the default drawer width. Note that there is a minimum .1 second duration for built in animations, to account for small distance animations. - */ -@property (nonatomic, assign) CGFloat animationVelocity; - -/** - A boolean that determines whether or not the panning gesture will "hard-stop" at the maximum width for a given drawer side. - - By default, this value is set to YES. Enabling `shouldStretchDrawer` will give the pan a gradual asymptotic stopping point much like `UIScrollView` behaves. Note that if this value is set to YES, the `drawerVisualStateBlock` can be passed a `percentVisible` greater than 1.0, so be sure to handle that case appropriately. - */ -@property (nonatomic, assign) BOOL shouldStretchDrawer; - -/** - The current open side of the drawer. - - Note this value will change as soon as a pan gesture opens a drawer, or when a open/close animation is finished. - */ -@property (nonatomic, assign, readonly) MMDrawerSide openSide; - -/** - How a user is allowed to open a drawer using gestures. - - By default, this is set to `MMOpenDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately. - */ -@property (nonatomic, assign) MMOpenDrawerGestureMode openDrawerGestureModeMask; - -/** - How a user is allowed to close a drawer. - - By default, this is set to `MMCloseDrawerGestureModeNone`. Note these gestures may affect user interaction with the `centerViewController`, so be sure to use appropriately. - */ -@property (nonatomic, assign) MMCloseDrawerGestureMode closeDrawerGestureModeMask; - -/** - The value determining if the user can interact with the `centerViewController` when a side drawer is open. - - By default, it is `MMDrawerOpenCenterInteractionModeNavigationBarOnly`, meaning that the user can only interact with the buttons on the `UINavigationBar`, if the center view controller is a `UINavigationController`. Otherwise, the user cannot interact with any other center view controller elements. - */ -@property (nonatomic, assign) MMDrawerOpenCenterInteractionMode centerHiddenInteractionMode; - -/** - The flag determining if a shadow should be drawn off of `centerViewController` when a drawer is open. - - By default, this is set to YES. - */ -@property (nonatomic, assign) BOOL showsShadow; - -/** - The shadow radius of `centerViewController` when a drawer is open. - - By default, this is set to 10.0f; - */ -@property (nonatomic, assign) CGFloat shadowRadius; - -/** - The shadow opacity of `centerViewController` when a drawer is open. - - By default, this is set to 0.8f; - */ -@property (nonatomic, assign) CGFloat shadowOpacity; - -/** - The shadow offset of `centerViewController` when a drawer is open. - - By default, this is set to (0, -3); - */ -@property (nonatomic, assign) CGSize shadowOffset; - -/** - The color of the shadow drawn off of 'centerViewController` when a drawer is open. - - By default, this is set to the systme default (opaque black). - */ -@property (nonatomic, strong) UIColor * shadowColor; - -/** - The flag determining if a custom background view should appear beneath the status bar, forcing the child content to be drawn lower than the status bar. - - By default, this is set to NO. - */ -@property (nonatomic, assign) BOOL showsStatusBarBackgroundView; - -/** - The color of the status bar background view if `showsStatusBarBackgroundView` is set to YES. - - By default, this is set `[UIColor blackColor]`. - */ -@property (nonatomic, strong) UIColor * statusBarViewBackgroundColor; - -/** - The value determining panning range of centerView's bezel if the user can open drawer with 'MMOpenDrawerGestureModeBezelPanningCenterView' or close drawer with 'MMCloseDrawerGestureModeBezelPanningCenterView' . - - By default, this is set 20.0f. - */ -@property (nonatomic, assign) CGFloat bezelPanningCenterViewRange; - -/** - The value determining if the user can open or close drawer with panGesture velocity. - - By default, this is set 200.0f. - */ -@property (nonatomic, assign) CGFloat panVelocityXAnimationThreshold; - -///--------------------------------------- -/// @name Initializing a `MMDrawerController` -///--------------------------------------- - -/** - Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller, and right drawer view controller. - - @param centerViewController The center view controller. This argument must not be `nil`. - @param leftDrawerViewController The left drawer view controller. - @param rightDrawerViewController The right drawer controller. - - @return The newly-initialized drawer container view controller. - */ --(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController; - -/** - Creates and initializes an `MMDrawerController` object with the specified center view controller, left drawer view controller. - - @param centerViewController The center view controller. This argument must not be `nil`. - @param leftDrawerViewController The left drawer view controller. - - @return The newly-initialized drawer container view controller. - */ --(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController; - -/** - Creates and initializes an `MMDrawerController` object with the specified center view controller, right drawer view controller. - - @param centerViewController The center view controller. This argument must not be `nil`. - @param rightDrawerViewController The right drawer controller. - - @return The newly-initialized drawer container view controller. - */ --(instancetype)initWithCenterViewController:(UIViewController *)centerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController; - -///--------------------------------------- -/// @name Opening and Closing a Drawer -///--------------------------------------- - -/** - Toggles the drawer open/closed based on the `drawer` passed in. - - Note that if you attempt to toggle a drawer closed while the other is open, nothing will happen. For example, if you pass in MMDrawerSideLeft, but the right drawer is open, nothing will happen. In addition, the completion block will be called with the finished flag set to NO. - - @param drawerSide The `MMDrawerSide` to toggle. This value cannot be `MMDrawerSideNone`. - @param animated Determines whether the `drawer` should be toggle animated. - @param completion The block that is called when the toggle is complete, or if no toggle took place at all. - - */ --(void)toggleDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; - -/** - Closes the open drawer. - - @param animated Determines whether the drawer side should be closed animated - @param completion The block that is called when the close is complete - - */ --(void)closeDrawerAnimated:(BOOL)animated completion:(void(^)(BOOL finished))completion; - -/** - Opens the `drawer` passed in. - - @param drawerSide The `MMDrawerSide` to open. This value cannot be `MMDrawerSideNone`. - @param animated Determines whether the `drawer` should be open animated. - @param completion The block that is called when the toggle is open. - - */ --(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; - -///--------------------------------------- -/// @name Setting a new Center View Controller -///--------------------------------------- - -/** - Sets the new `centerViewController`. - - This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeAnimated` is YES, it will immediately change the center view controller, and close the drawer from its current position. - - @param centerViewController The new `centerViewController`. - @param closeAnimated Determines whether the drawer should be closed with an animation. - @param completion The block called when the animation is finsihed. - - */ --(void)setCenterViewController:(UIViewController *)centerViewController withCloseAnimation:(BOOL)closeAnimated completion:(void(^)(BOOL finished))completion; - -/** - Sets the new `centerViewController`. - - This sets the view controller and will automatically adjust the frame based on the current state of the drawer controller. If `closeFullAnimated` is YES, the current center view controller will animate off the screen, the new center view controller will then be set, followed by the drawer closing across the full width of the screen. - - @param newCenterViewController The new `centerViewController`. - @param fullCloseAnimated Determines whether the drawer should be closed with an animation. - @param completion The block called when the animation is finsihed. - - */ --(void)setCenterViewController:(UIViewController *)newCenterViewController withFullCloseAnimation:(BOOL)fullCloseAnimated completion:(void(^)(BOOL finished))completion; - -///--------------------------------------- -/// @name Animating the Width of a Drawer -///--------------------------------------- - -/** - Sets the maximum width of the left drawer view controller. - - If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately. - - @param width The new width of left drawer view controller. This must be greater than zero. - @param animated Determines whether the drawer should be adjusted with an animation. - @param completion The block called when the animation is finished. - - */ --(void)setMaximumLeftDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; - -/** - Sets the maximum width of the right drawer view controller. - - If the drawer is open, and `animated` is YES, it will animate the drawer frame as well as adjust the center view controller. If the drawer is not open, this change will take place immediately. - - @param width The new width of right drawer view controller. This must be greater than zero. - @param animated Determines whether the drawer should be adjusted with an animation. - @param completion The block called when the animation is finished. - - */ --(void)setMaximumRightDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion; - -///--------------------------------------- -/// @name Previewing a Drawer -///--------------------------------------- - -/** - Bounce preview for the specified `drawerSide` a distance of 40 points. - - @param drawerSide The drawer to preview. This value cannot be `MMDrawerSideNone`. - @param completion The block called when the animation is finsihed. - - */ --(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide completion:(void(^)(BOOL finished))completion; - -/** - Bounce preview for the specified `drawerSide`. - - @param drawerSide The drawer side to preview. This value cannot be `MMDrawerSideNone`. - @param distance The distance to bounce. - @param completion The block called when the animation is finsihed. - - */ --(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide distance:(CGFloat)distance completion:(void(^)(BOOL finished))completion; - -///--------------------------------------- -/// @name Custom Drawer Animations -///--------------------------------------- - -/** - Sets a callback to be called when a drawer visual state needs to be updated. - - This block is responsible for updating the drawer's view state, and the drawer controller will handle animating to that state from the current state. This block will be called when the drawer is opened or closed, as well when the user is panning the drawer. This block is not responsible for doing animations directly, but instead just updating the state of the properies (such as alpha, anchor point, transform, etc). Note that if `shouldStretchDrawer` is set to YES, it is possible for `percentVisible` to be greater than 1.0. If `shouldStretchDrawer` is set to NO, `percentVisible` will never be greater than 1.0. - - Note that when the drawer is finished opening or closing, the side drawer controller view will be reset with the following properies: - - - alpha: 1.0 - - transform: CATransform3DIdentity - - anchorPoint: (0.5,0.5) - - @param drawerVisualStateBlock A block object to be called that allows the implementer to update visual state properties on the drawer. `percentVisible` represents the amount of the drawer space that is current visible, with drawer space being defined as the edge of the screen to the maxmimum drawer width. Note that you do have access to the drawerController, which will allow you to update things like the anchor point of the side drawer layer. - */ --(void)setDrawerVisualStateBlock:(void(^)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible))drawerVisualStateBlock; - -///--------------------------------------- -/// @name Gesture Completion Handling -///--------------------------------------- - -/** - Sets a callback to be called when a gesture has been completed. - - This block is called when a gesture action has been completed. You can query the `openSide` of the `drawerController` to determine what the new state of the drawer is. - - @param gestureCompletionBlock A block object to be called that allows the implementer be notified when a gesture action has been completed. - */ --(void)setGestureCompletionBlock:(void(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture))gestureCompletionBlock; - -///--------------------------------------- -/// @name Custom Gesture Handler -///--------------------------------------- - -/** - Sets a callback to be called to determine if a UIGestureRecognizer should recieve the given UITouch. - - This block provides a way to allow a gesture to be recognized with custom logic. For example, you may have a certain part of your view that should accept a pan gesture recognizer to open the drawer, but not another a part. If you return YES, the gesture is recognized and the appropriate action is taken. This provides similar support to how Facebook allows you to pan on the background view of the main table view, but not the content itself. You can inspect the `openSide` property of the `drawerController` to determine the current state of the drawer, and apply the appropriate logic within your block. - - Note that either `openDrawerGestureModeMask` must contain `MMOpenDrawerGestureModeCustom`, or `closeDrawerGestureModeMask` must contain `MMCloseDrawerGestureModeCustom` for this block to be consulted. - - @param gestureShouldRecognizeTouchBlock A block object to be called to determine if the given `touch` should be recognized by the given gesture. - */ --(void)setGestureShouldRecognizeTouchBlock:(BOOL(^)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch))gestureShouldRecognizeTouchBlock; - -@end diff --git a/WBSBlog/Lib/MMDrawerController/MMDrawerController.m b/WBSBlog/Lib/MMDrawerController/MMDrawerController.m deleted file mode 100755 index ba3981b..0000000 --- a/WBSBlog/Lib/MMDrawerController/MMDrawerController.m +++ /dev/null @@ -1,1465 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#import "MMDrawerController.h" -#import "UIViewController+MMDrawerController.h" - -#import - -CGFloat const MMDrawerDefaultWidth = 280.0f; -CGFloat const MMDrawerDefaultAnimationVelocity = 840.0f; - -NSTimeInterval const MMDrawerDefaultFullAnimationDelay = 0.10f; - -CGFloat const MMDrawerDefaultBounceDistance = 50.0f; - -NSTimeInterval const MMDrawerDefaultBounceAnimationDuration = 0.2f; -CGFloat const MMDrawerDefaultSecondBounceDistancePercentage = .25f; - -CGFloat const MMDrawerDefaultShadowRadius = 10.0f; -CGFloat const MMDrawerDefaultShadowOpacity = 0.8; - -NSTimeInterval const MMDrawerMinimumAnimationDuration = 0.15f; - -CGFloat const MMDrawerBezelRange = 20.0f; - -CGFloat const MMDrawerPanVelocityXAnimationThreshold = 200.0f; - -/** The amount of overshoot that is panned linearly. The remaining percentage nonlinearly asymptotes to the max percentage. */ -CGFloat const MMDrawerOvershootLinearRangePercentage = 0.75f; - -/** The percent of the possible overshoot width to use as the actual overshoot percentage. */ -CGFloat const MMDrawerOvershootPercentage = 0.1f; - -typedef BOOL (^MMDrawerGestureShouldRecognizeTouchBlock)(MMDrawerController * drawerController, UIGestureRecognizer * gesture, UITouch * touch); -typedef void (^MMDrawerGestureCompletionBlock)(MMDrawerController * drawerController, UIGestureRecognizer * gesture); - -static CAKeyframeAnimation * bounceKeyFrameAnimationForDistanceOnView(CGFloat distance, UIView * view) { - CGFloat factors[32] = {0, 32, 60, 83, 100, 114, 124, 128, 128, 124, 114, 100, 83, 60, 32, - 0, 24, 42, 54, 62, 64, 62, 54, 42, 24, 0, 18, 28, 32, 28, 18, 0}; - - NSMutableArray *values = [NSMutableArray array]; - - for (int i=0; i<32; i++) - { - CGFloat positionOffset = factors[i]/128.0f * distance + CGRectGetMidX(view.bounds); - [values addObject:@(positionOffset)]; - } - - CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.x"]; - animation.repeatCount = 1; - animation.duration = .8; - animation.fillMode = kCAFillModeForwards; - animation.values = values; - animation.removedOnCompletion = YES; - animation.autoreverses = NO; - - return animation; -} - -static NSString *MMDrawerLeftDrawerKey = @"MMDrawerLeftDrawer"; -static NSString *MMDrawerRightDrawerKey = @"MMDrawerRightDrawer"; -static NSString *MMDrawerCenterKey = @"MMDrawerCenter"; -static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide"; - -@interface MMDrawerCenterContainerView : UIView -@property (nonatomic,assign) MMDrawerOpenCenterInteractionMode centerInteractionMode; -@property (nonatomic,assign) MMDrawerSide openSide; -@end - -@implementation MMDrawerCenterContainerView - --(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{ - UIView *hitView = [super hitTest:point withEvent:event]; - if(hitView && - self.openSide != MMDrawerSideNone){ - UINavigationBar * navBar = [self navigationBarContainedWithinSubviewsOfView:self]; - CGRect navBarFrame = [navBar convertRect:navBar.bounds toView:self]; - if((self.centerInteractionMode == MMDrawerOpenCenterInteractionModeNavigationBarOnly && - CGRectContainsPoint(navBarFrame, point) == NO) || - self.centerInteractionMode == MMDrawerOpenCenterInteractionModeNone){ - hitView = nil; - } - } - return hitView; -} - --(UINavigationBar*)navigationBarContainedWithinSubviewsOfView:(UIView*)view{ - UINavigationBar * navBar = nil; - for(UIView * subview in [view subviews]){ - if([view isKindOfClass:[UINavigationBar class]]){ - navBar = (UINavigationBar*)view; - break; - } - else { - navBar = [self navigationBarContainedWithinSubviewsOfView:subview]; - if (navBar != nil) { - break; - } - } - } - return navBar; -} -@end - -@interface MMDrawerController () { - CGFloat _maximumRightDrawerWidth; - CGFloat _maximumLeftDrawerWidth; - UIColor * _statusBarViewBackgroundColor; -} - -@property (nonatomic, assign, readwrite) MMDrawerSide openSide; - -@property (nonatomic, strong) UIView * childControllerContainerView; -@property (nonatomic, strong) MMDrawerCenterContainerView * centerContainerView; -@property (nonatomic, strong) UIView * dummyStatusBarView; - -@property (nonatomic, assign) CGRect startingPanRect; -@property (nonatomic, copy) MMDrawerControllerDrawerVisualStateBlock drawerVisualState; -@property (nonatomic, copy) MMDrawerGestureShouldRecognizeTouchBlock gestureShouldRecognizeTouch; -@property (nonatomic, copy) MMDrawerGestureCompletionBlock gestureCompletion; -@property (nonatomic, assign, getter = isAnimatingDrawer) BOOL animatingDrawer; - -@end - -@implementation MMDrawerController - -#pragma mark - Init - -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - if (self) { - [self commonSetup]; - } - return self; -} - -- (id)initWithCoder:(NSCoder *)aDecoder{ - self = [super initWithCoder:aDecoder]; - if (self) { - [self commonSetup]; - } - return self; -} - --(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController{ - NSParameterAssert(centerViewController); - self = [super init]; - if(self){ - [self setCenterViewController:centerViewController]; - [self setLeftDrawerViewController:leftDrawerViewController]; - [self setRightDrawerViewController:rightDrawerViewController]; - } - return self; -} - --(instancetype)initWithCenterViewController:(UIViewController *)centerViewController leftDrawerViewController:(UIViewController *)leftDrawerViewController{ - return [self initWithCenterViewController:centerViewController leftDrawerViewController:leftDrawerViewController rightDrawerViewController:nil]; -} - --(instancetype)initWithCenterViewController:(UIViewController *)centerViewController rightDrawerViewController:(UIViewController *)rightDrawerViewController{ - return [self initWithCenterViewController:centerViewController leftDrawerViewController:nil rightDrawerViewController:rightDrawerViewController]; -} - --(void)commonSetup{ - [self setMaximumLeftDrawerWidth:MMDrawerDefaultWidth]; - [self setMaximumRightDrawerWidth:MMDrawerDefaultWidth]; - - [self setAnimationVelocity:MMDrawerDefaultAnimationVelocity]; - - [self setShowsShadow:YES]; - [self setShouldStretchDrawer:YES]; - - [self setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone]; - [self setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeNone]; - [self setCenterHiddenInteractionMode:MMDrawerOpenCenterInteractionModeNavigationBarOnly]; - - // set shadow related default values - [self setShadowOpacity:MMDrawerDefaultShadowOpacity]; - [self setShadowRadius:MMDrawerDefaultShadowRadius]; - [self setShadowOffset:CGSizeMake(0, -3)]; - [self setShadowColor:[UIColor blackColor]]; - - // set default bezel range for panGestureReconizer - [self setBezelPanningCenterViewRange:MMDrawerBezelRange]; - - // set defualt panVelocityXAnimationThreshold - [self setPanVelocityXAnimationThreshold:MMDrawerPanVelocityXAnimationThreshold]; -} - -#pragma mark - State Restoration -- (void)encodeRestorableStateWithCoder:(NSCoder *)coder{ - [super encodeRestorableStateWithCoder:coder]; - if (self.leftDrawerViewController){ - [coder encodeObject:self.leftDrawerViewController forKey:MMDrawerLeftDrawerKey]; - } - - if (self.rightDrawerViewController){ - [coder encodeObject:self.rightDrawerViewController forKey:MMDrawerRightDrawerKey]; - } - - if (self.centerViewController){ - [coder encodeObject:self.centerViewController forKey:MMDrawerCenterKey]; - } - - [coder encodeInteger:self.openSide forKey:MMDrawerOpenSideKey]; -} - -- (void)decodeRestorableStateWithCoder:(NSCoder *)coder{ - UIViewController *controller; - MMDrawerSide openside; - - [super decodeRestorableStateWithCoder:coder]; - - if ((controller = [coder decodeObjectForKey:MMDrawerLeftDrawerKey])){ - self.leftDrawerViewController = controller; - } - - if ((controller = [coder decodeObjectForKey:MMDrawerRightDrawerKey])){ - self.rightDrawerViewController = controller; - } - - if ((controller = [coder decodeObjectForKey:MMDrawerCenterKey])){ - self.centerViewController = controller; - } - - if ((openside = [coder decodeIntegerForKey:MMDrawerOpenSideKey])){ - [self openDrawerSide:openside animated:false completion:nil]; - } -} -#pragma mark - Open/Close methods --(void)toggleDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion{ - NSParameterAssert(drawerSide!=MMDrawerSideNone); - if(self.openSide == MMDrawerSideNone){ - [self openDrawerSide:drawerSide animated:animated completion:completion]; - } - else { - if((drawerSide == MMDrawerSideLeft && - self.openSide == MMDrawerSideLeft) || - (drawerSide == MMDrawerSideRight && - self.openSide == MMDrawerSideRight)){ - [self closeDrawerAnimated:animated completion:completion]; - } - else if(completion){ - completion(NO); - } - } -} - --(void)closeDrawerAnimated:(BOOL)animated completion:(void (^)(BOOL finished))completion{ - [self closeDrawerAnimated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion]; -} - --(void)closeDrawerAnimated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{ - if(self.isAnimatingDrawer){ - if(completion){ - completion(NO); - } - } - else { - [self setAnimatingDrawer:animated]; - CGRect newFrame = self.childControllerContainerView.bounds; - - CGFloat distance = ABS(CGRectGetMinX(self.centerContainerView.frame)); - NSTimeInterval duration = MAX(distance/ABS(velocity),MMDrawerMinimumAnimationDuration); - - BOOL leftDrawerVisible = CGRectGetMinX(self.centerContainerView.frame) > 0; - BOOL rightDrawerVisible = CGRectGetMinX(self.centerContainerView.frame) < 0; - - MMDrawerSide visibleSide = MMDrawerSideNone; - CGFloat percentVisble = 0.0; - - if(leftDrawerVisible){ - CGFloat visibleDrawerPoints = CGRectGetMinX(self.centerContainerView.frame); - percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumLeftDrawerWidth); - visibleSide = MMDrawerSideLeft; - } - else if(rightDrawerVisible){ - CGFloat visibleDrawerPoints = CGRectGetWidth(self.centerContainerView.frame)-CGRectGetMaxX(self.centerContainerView.frame); - percentVisble = MAX(0.0,visibleDrawerPoints/self.maximumRightDrawerWidth); - visibleSide = MMDrawerSideRight; - } - - UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:visibleSide]; - - [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisble]; - - [sideDrawerViewController beginAppearanceTransition:NO animated:animated]; - - [UIView - animateWithDuration:(animated?duration:0.0) - delay:0.0 - options:options - animations:^{ - [self setNeedsStatusBarAppearanceUpdateIfSupported]; - [self.centerContainerView setFrame:newFrame]; - [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:0.0]; - } - completion:^(BOOL finished) { - [sideDrawerViewController endAppearanceTransition]; - [self setOpenSide:MMDrawerSideNone]; - [self resetDrawerVisualStateForDrawerSide:visibleSide]; - [self setAnimatingDrawer:NO]; - if(completion){ - completion(finished); - } - }]; - } -} - --(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void (^)(BOOL finished))completion{ - NSParameterAssert(drawerSide != MMDrawerSideNone); - - [self openDrawerSide:drawerSide animated:animated velocity:self.animationVelocity animationOptions:UIViewAnimationOptionCurveEaseInOut completion:completion]; -} - --(void)openDrawerSide:(MMDrawerSide)drawerSide animated:(BOOL)animated velocity:(CGFloat)velocity animationOptions:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion{ - NSParameterAssert(drawerSide != MMDrawerSideNone); - if (self.isAnimatingDrawer) { - if(completion){ - completion(NO); - } - } - else { - [self setAnimatingDrawer:animated]; - UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; - if (self.openSide != drawerSide) { - [self prepareToPresentDrawer:drawerSide animated:animated]; - } - - if(sideDrawerViewController){ - CGRect newFrame; - CGRect oldFrame = self.centerContainerView.frame; - if(drawerSide == MMDrawerSideLeft){ - newFrame = self.centerContainerView.frame; - newFrame.origin.x = self.maximumLeftDrawerWidth; - } - else { - newFrame = self.centerContainerView.frame; - newFrame.origin.x = 0-self.maximumRightDrawerWidth; - } - - CGFloat distance = ABS(CGRectGetMinX(oldFrame)-newFrame.origin.x); - NSTimeInterval duration = MAX(distance/ABS(velocity),MMDrawerMinimumAnimationDuration); - - [UIView - animateWithDuration:(animated?duration:0.0) - delay:0.0 - options:options - animations:^{ - [self setNeedsStatusBarAppearanceUpdateIfSupported]; - [self.centerContainerView setFrame:newFrame]; - [self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0]; - } - completion:^(BOOL finished) { - //End the appearance transition if it already wasn't open. - if(drawerSide != self.openSide){ - [sideDrawerViewController endAppearanceTransition]; - } - [self setOpenSide:drawerSide]; - - [self resetDrawerVisualStateForDrawerSide:drawerSide]; - [self setAnimatingDrawer:NO]; - if(completion){ - completion(finished); - } - }]; - } - } -} - -#pragma mark - Updating the Center View Controller -//If animated is NO, then we need to handle all the appearance calls within this method. Otherwise, -//let the method calling this one handle proper appearance methods since they will have more context --(void)setCenterViewController:(UIViewController *)centerViewController animated:(BOOL)animated{ - if ([self.centerViewController isEqual:centerViewController]) { - return; - } - - if (_centerContainerView == nil) { - //This is related to Issue #152 (https://github.com/mutualmobile/MMDrawerController/issues/152) - // also fixed below in the getter for `childControllerContainerView`. Turns out we have - // two center container views getting added to the view during init, - // because the first request self.centerContainerView.bounds was kicking off a - // viewDidLoad, which caused us to be able to fall through this check twice. - // - //The fix is to grab the bounds, and then check again that the child container view has - //not been created. - - CGRect centerFrame = self.childControllerContainerView.bounds; - if(_centerContainerView == nil){ - _centerContainerView = [[MMDrawerCenterContainerView alloc] initWithFrame:centerFrame]; - [self.centerContainerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; - [self.centerContainerView setBackgroundColor:[UIColor clearColor]]; - [self.centerContainerView setOpenSide:self.openSide]; - [self.centerContainerView setCenterInteractionMode:self.centerHiddenInteractionMode]; - [self.childControllerContainerView addSubview:self.centerContainerView]; - } - } - - UIViewController * oldCenterViewController = self.centerViewController; - if(oldCenterViewController){ - [oldCenterViewController willMoveToParentViewController:nil]; - if(animated == NO){ - [oldCenterViewController beginAppearanceTransition:NO animated:NO]; - } - [oldCenterViewController.view removeFromSuperview]; - if(animated == NO){ - [oldCenterViewController endAppearanceTransition]; - } - [oldCenterViewController removeFromParentViewController]; - } - - _centerViewController = centerViewController; - - [self addChildViewController:self.centerViewController]; - [self.centerViewController.view setFrame:self.childControllerContainerView.bounds]; - [self.centerContainerView addSubview:self.centerViewController.view]; - [self.childControllerContainerView bringSubviewToFront:self.centerContainerView]; - [self.centerViewController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight]; - [self updateShadowForCenterView]; - - if(animated == NO){ - // If drawer is offscreen, then viewWillAppear: will take care of this - if(self.view.window) { - [self.centerViewController beginAppearanceTransition:YES animated:NO]; - [self.centerViewController endAppearanceTransition]; - } - [self.centerViewController didMoveToParentViewController:self]; - } -} - --(void)setCenterViewController:(UIViewController *)newCenterViewController withCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{ - - if(self.openSide == MMDrawerSideNone){ - //If a side drawer isn't open, there is nothing to animate... - animated = NO; - } - - BOOL forwardAppearanceMethodsToCenterViewController = ([self.centerViewController isEqual:newCenterViewController] == NO); - [self setCenterViewController:newCenterViewController animated:animated]; - - if(animated){ - [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:1.0]; - if (forwardAppearanceMethodsToCenterViewController) { - [self.centerViewController beginAppearanceTransition:YES animated:animated]; - } - [self - closeDrawerAnimated:animated - completion:^(BOOL finished) { - if (forwardAppearanceMethodsToCenterViewController) { - [self.centerViewController endAppearanceTransition]; - [self.centerViewController didMoveToParentViewController:self]; - } - if(completion){ - completion(finished); - } - }]; - } - else { - if(completion) { - completion(YES); - } - } -} - --(void)setCenterViewController:(UIViewController *)newCenterViewController withFullCloseAnimation:(BOOL)animated completion:(void(^)(BOOL finished))completion{ - if(self.openSide != MMDrawerSideNone && - animated){ - - BOOL forwardAppearanceMethodsToCenterViewController = ([self.centerViewController isEqual:newCenterViewController] == NO); - - UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:self.openSide]; - - CGFloat targetClosePoint = 0.0f; - if(self.openSide == MMDrawerSideRight){ - targetClosePoint = -CGRectGetWidth(self.childControllerContainerView.bounds); - } - else if(self.openSide == MMDrawerSideLeft) { - targetClosePoint = CGRectGetWidth(self.childControllerContainerView.bounds); - } - - CGFloat distance = ABS(self.centerContainerView.frame.origin.x-targetClosePoint); - NSTimeInterval firstDuration = [self animationDurationForAnimationDistance:distance]; - - CGRect newCenterRect = self.centerContainerView.frame; - - [self setAnimatingDrawer:animated]; - - UIViewController * oldCenterViewController = self.centerViewController; - if(forwardAppearanceMethodsToCenterViewController ){ - [oldCenterViewController beginAppearanceTransition:NO animated:animated]; - } - newCenterRect.origin.x = targetClosePoint; - [UIView - animateWithDuration:firstDuration - delay:0.0 - options:UIViewAnimationOptionCurveEaseInOut - animations:^{ - [self.centerContainerView setFrame:newCenterRect]; - [sideDrawerViewController.view setFrame:self.childControllerContainerView.bounds]; - } - completion:^(BOOL finished) { - - CGRect oldCenterRect = self.centerContainerView.frame; - [self setCenterViewController:newCenterViewController animated:animated]; - [self.centerContainerView setFrame:oldCenterRect]; - [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:1.0]; - if(forwardAppearanceMethodsToCenterViewController) { - [oldCenterViewController endAppearanceTransition]; - [self.centerViewController beginAppearanceTransition:YES animated:animated]; - } - [sideDrawerViewController beginAppearanceTransition:NO animated:animated]; - [UIView - animateWithDuration:[self animationDurationForAnimationDistance:CGRectGetWidth(self.childControllerContainerView.bounds)] - delay:MMDrawerDefaultFullAnimationDelay - options:UIViewAnimationOptionCurveEaseInOut - animations:^{ - [self.centerContainerView setFrame:self.childControllerContainerView.bounds]; - [self updateDrawerVisualStateForDrawerSide:self.openSide percentVisible:0.0]; - } - completion:^(BOOL finished) { - if (forwardAppearanceMethodsToCenterViewController) { - [self.centerViewController endAppearanceTransition]; - [self.centerViewController didMoveToParentViewController:self]; - } - [sideDrawerViewController endAppearanceTransition]; - [self resetDrawerVisualStateForDrawerSide:self.openSide]; - - [sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame]; - - [self setOpenSide:MMDrawerSideNone]; - [self setAnimatingDrawer:NO]; - if(completion){ - completion(finished); - } - }]; - }]; - } - else { - [self setCenterViewController:newCenterViewController animated:animated]; - if(self.openSide != MMDrawerSideNone){ - [self closeDrawerAnimated:animated completion:completion]; - } - else if(completion){ - completion(YES); - } - } -} - -#pragma mark - Size Methods --(void)setMaximumLeftDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{ - [self setMaximumDrawerWidth:width forSide:MMDrawerSideLeft animated:animated completion:completion]; -} - --(void)setMaximumRightDrawerWidth:(CGFloat)width animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{ - [self setMaximumDrawerWidth:width forSide:MMDrawerSideRight animated:animated completion:completion]; -} - -- (void)setMaximumDrawerWidth:(CGFloat)width forSide:(MMDrawerSide)drawerSide animated:(BOOL)animated completion:(void(^)(BOOL finished))completion{ - NSParameterAssert(width > 0); - NSParameterAssert(drawerSide != MMDrawerSideNone); - - UIViewController *sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; - CGFloat oldWidth = 0.f; - NSInteger drawerSideOriginCorrection = 1; - if (drawerSide == MMDrawerSideLeft) { - oldWidth = _maximumLeftDrawerWidth; - _maximumLeftDrawerWidth = width; - } - else if(drawerSide == MMDrawerSideRight){ - oldWidth = _maximumRightDrawerWidth; - _maximumRightDrawerWidth = width; - drawerSideOriginCorrection = -1; - } - - CGFloat distance = ABS(width-oldWidth); - NSTimeInterval duration = [self animationDurationForAnimationDistance:distance]; - - if(self.openSide == drawerSide){ - CGRect newCenterRect = self.centerContainerView.frame; - newCenterRect.origin.x = drawerSideOriginCorrection*width; - [UIView - animateWithDuration:(animated?duration:0) - delay:0.0 - options:UIViewAnimationOptionCurveEaseInOut - animations:^{ - [self.centerContainerView setFrame:newCenterRect]; - [sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame]; - } - completion:^(BOOL finished) { - if(completion != nil){ - completion(finished); - } - }]; - } - else{ - [sideDrawerViewController.view setFrame:sideDrawerViewController.mm_visibleDrawerFrame]; - if(completion != nil){ - completion(YES); - } - } -} - -#pragma mark - Bounce Methods --(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide completion:(void(^)(BOOL finished))completion{ - NSParameterAssert(drawerSide!=MMDrawerSideNone); - [self bouncePreviewForDrawerSide:drawerSide distance:MMDrawerDefaultBounceDistance completion:nil]; -} - --(void)bouncePreviewForDrawerSide:(MMDrawerSide)drawerSide distance:(CGFloat)distance completion:(void(^)(BOOL finished))completion{ - NSParameterAssert(drawerSide!=MMDrawerSideNone); - - UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; - - if(sideDrawerViewController == nil || - self.openSide != MMDrawerSideNone){ - if(completion){ - completion(NO); - } - return; - } - else { - [self prepareToPresentDrawer:drawerSide animated:YES]; - - [self updateDrawerVisualStateForDrawerSide:drawerSide percentVisible:1.0]; - - [CATransaction begin]; - [CATransaction - setCompletionBlock:^{ - [sideDrawerViewController endAppearanceTransition]; - [sideDrawerViewController beginAppearanceTransition:NO animated:NO]; - [sideDrawerViewController endAppearanceTransition]; - if(completion){ - completion(YES); - } - }]; - - CGFloat modifier = ((drawerSide == MMDrawerSideLeft)?1.0:-1.0); - CAKeyframeAnimation *animation = bounceKeyFrameAnimationForDistanceOnView(distance*modifier,self.centerContainerView); - [self.centerContainerView.layer addAnimation:animation forKey:@"bouncing"]; - - [CATransaction commit]; - } -} - -#pragma mark - Setting Drawer Visual State --(void)setDrawerVisualStateBlock:(void (^)(MMDrawerController *, MMDrawerSide, CGFloat))drawerVisualStateBlock{ - [self setDrawerVisualState:drawerVisualStateBlock]; -} - -#pragma mark - Setting Custom Gesture Handler Block --(void)setGestureShouldRecognizeTouchBlock:(BOOL (^)(MMDrawerController *, UIGestureRecognizer *, UITouch *))gestureShouldRecognizeTouchBlock{ - [self setGestureShouldRecognizeTouch:gestureShouldRecognizeTouchBlock]; -} - -#pragma mark - Setting the Gesture Completion Block --(void)setGestureCompletionBlock:(void (^)(MMDrawerController *, UIGestureRecognizer *))gestureCompletionBlock{ - [self setGestureCompletion:gestureCompletionBlock]; -} - -#pragma mark - Subclass Methods --(BOOL)shouldAutomaticallyForwardAppearanceMethods{ - return NO; -} - --(BOOL)shouldAutomaticallyForwardRotationMethods{ - return NO; -} - --(BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers{ - return NO; -} - -#pragma mark - View Lifecycle - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self.view setBackgroundColor:[UIColor blackColor]]; - - [self setupGestureRecognizers]; -} - --(void)viewWillAppear:(BOOL)animated{ - [super viewWillAppear:animated]; - [self.centerViewController beginAppearanceTransition:YES animated:animated]; - - if(self.openSide == MMDrawerSideLeft) { - [self.leftDrawerViewController beginAppearanceTransition:YES animated:animated]; - } - else if(self.openSide == MMDrawerSideRight) { - [self.rightDrawerViewController beginAppearanceTransition:YES animated:animated]; - } -} - --(void)viewDidAppear:(BOOL)animated{ - [super viewDidAppear:animated]; - [self updateShadowForCenterView]; - [self.centerViewController endAppearanceTransition]; - - if(self.openSide == MMDrawerSideLeft) { - [self.leftDrawerViewController endAppearanceTransition]; - } - else if(self.openSide == MMDrawerSideRight) { - [self.rightDrawerViewController endAppearanceTransition]; - } -} - --(void)viewWillDisappear:(BOOL)animated{ - [super viewWillDisappear:animated]; - [self.centerViewController beginAppearanceTransition:NO animated:animated]; - if(self.openSide == MMDrawerSideLeft) { - [self.leftDrawerViewController beginAppearanceTransition:NO animated:animated]; - } - else if (self.openSide == MMDrawerSideRight) { - [self.rightDrawerViewController beginAppearanceTransition:NO animated:animated]; - } -} - --(void)viewDidDisappear:(BOOL)animated{ - [super viewDidDisappear:animated]; - [self.centerViewController endAppearanceTransition]; - if(self.openSide == MMDrawerSideLeft) { - [self.leftDrawerViewController endAppearanceTransition]; - } - else if (self.openSide == MMDrawerSideRight) { - [self.rightDrawerViewController endAppearanceTransition]; - } -} - -#pragma mark Rotation - --(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ - [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; - //If a rotation begins, we are going to cancel the current gesture and reset transform and anchor points so everything works correctly - BOOL gestureInProgress = NO; - for(UIGestureRecognizer * gesture in self.view.gestureRecognizers){ - if(gesture.state == UIGestureRecognizerStateChanged){ - [gesture setEnabled:NO]; - [gesture setEnabled:YES]; - gestureInProgress = YES; - } - if (gestureInProgress) { - [self resetDrawerVisualStateForDrawerSide:self.openSide]; - } - } - if ([self needsManualForwardingOfRotationEvents]){ - for(UIViewController * childViewController in self.childViewControllers){ - [childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration]; - } - } - -} --(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ - [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; - //We need to support the shadow path rotation animation - //Inspired from here: http://blog.radi.ws/post/8348898129/calayers-shadowpath-and-uiview-autoresizing - if(self.showsShadow){ - CGPathRef oldShadowPath = self.centerContainerView.layer.shadowPath; - if(oldShadowPath){ - CFRetain(oldShadowPath); - } - - [self updateShadowForCenterView]; - - if (oldShadowPath) { - [self.centerContainerView.layer addAnimation:((^ { - CABasicAnimation *transition = [CABasicAnimation animationWithKeyPath:@"shadowPath"]; - transition.fromValue = (__bridge id)oldShadowPath; - transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; - transition.duration = duration; - return transition; - })()) forKey:@"transition"]; - CFRelease(oldShadowPath); - } - } - - if ([self needsManualForwardingOfRotationEvents]){ - for(UIViewController * childViewController in self.childViewControllers){ - [childViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration]; - } - } -} - --(BOOL)shouldAutorotate{ - return YES; -} - --(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{ - [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; - if ([self needsManualForwardingOfRotationEvents]){ - for(UIViewController * childViewController in self.childViewControllers){ - [childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation]; - } - } -} - -#pragma mark - Setters --(void)setRightDrawerViewController:(UIViewController *)rightDrawerViewController{ - [self setDrawerViewController:rightDrawerViewController forSide:MMDrawerSideRight]; -} - --(void)setLeftDrawerViewController:(UIViewController *)leftDrawerViewController{ - [self setDrawerViewController:leftDrawerViewController forSide:MMDrawerSideLeft]; -} - -- (void)setDrawerViewController:(UIViewController *)viewController forSide:(MMDrawerSide)drawerSide{ - NSParameterAssert(drawerSide != MMDrawerSideNone); - - UIViewController *currentSideViewController = [self sideDrawerViewControllerForSide:drawerSide]; - - if (currentSideViewController == viewController) { - return; - } - - if (currentSideViewController != nil) { - [currentSideViewController beginAppearanceTransition:NO animated:NO]; - [currentSideViewController.view removeFromSuperview]; - [currentSideViewController endAppearanceTransition]; - [currentSideViewController willMoveToParentViewController:nil]; - [currentSideViewController removeFromParentViewController]; - } - - UIViewAutoresizing autoResizingMask = 0; - if (drawerSide == MMDrawerSideLeft) { - _leftDrawerViewController = viewController; - autoResizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; - - } - else if(drawerSide == MMDrawerSideRight){ - _rightDrawerViewController = viewController; - autoResizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; - } - - if(viewController){ - [self addChildViewController:viewController]; - - if((self.openSide == drawerSide) && - [self.childControllerContainerView.subviews containsObject:self.centerContainerView]){ - [self.childControllerContainerView insertSubview:viewController.view belowSubview:self.centerContainerView]; - [viewController beginAppearanceTransition:YES animated:NO]; - [viewController endAppearanceTransition]; - } - else{ - [self.childControllerContainerView addSubview:viewController.view]; - [self.childControllerContainerView sendSubviewToBack:viewController.view]; - [viewController.view setHidden:YES]; - } - [viewController didMoveToParentViewController:self]; - [viewController.view setAutoresizingMask:autoResizingMask]; - [viewController.view setFrame:viewController.mm_visibleDrawerFrame]; - } -} - --(void)setCenterViewController:(UIViewController *)centerViewController{ - [self setCenterViewController:centerViewController animated:NO]; -} - --(void)setShowsShadow:(BOOL)showsShadow{ - _showsShadow = showsShadow; - [self updateShadowForCenterView]; -} - -- (void)setShadowRadius:(CGFloat)shadowRadius{ - _shadowRadius = shadowRadius; - [self updateShadowForCenterView]; -} - -- (void)setShadowOpacity:(CGFloat)shadowOpacity{ - _shadowOpacity = shadowOpacity; - [self updateShadowForCenterView]; -} - -- (void)setShadowOffset:(CGSize)shadowOffset{ - _shadowOffset = shadowOffset; - [self updateShadowForCenterView]; -} - -- (void)setShadowColor:(UIColor *)shadowColor{ - _shadowColor = shadowColor; - [self updateShadowForCenterView]; -} - --(void)setOpenSide:(MMDrawerSide)openSide{ - if(_openSide != openSide){ - _openSide = openSide; - [self.centerContainerView setOpenSide:openSide]; - if(openSide == MMDrawerSideNone){ - [self.leftDrawerViewController.view setHidden:YES]; - [self.rightDrawerViewController.view setHidden:YES]; - } - [self setNeedsStatusBarAppearanceUpdateIfSupported]; - } -} - --(void)setCenterHiddenInteractionMode:(MMDrawerOpenCenterInteractionMode)centerHiddenInteractionMode{ - if(_centerHiddenInteractionMode!=centerHiddenInteractionMode){ - _centerHiddenInteractionMode = centerHiddenInteractionMode; - [self.centerContainerView setCenterInteractionMode:centerHiddenInteractionMode]; - } -} - --(void)setMaximumLeftDrawerWidth:(CGFloat)maximumLeftDrawerWidth{ - [self setMaximumLeftDrawerWidth:maximumLeftDrawerWidth animated:NO completion:nil]; -} - --(void)setMaximumRightDrawerWidth:(CGFloat)maximumRightDrawerWidth{ - [self setMaximumRightDrawerWidth:maximumRightDrawerWidth animated:NO completion:nil]; -} - --(void)setShowsStatusBarBackgroundView:(BOOL)showsDummyStatusBar{ - if(showsDummyStatusBar!=_showsStatusBarBackgroundView){ - _showsStatusBarBackgroundView = showsDummyStatusBar; - CGRect frame = self.childControllerContainerView.frame; - if(_showsStatusBarBackgroundView){ - frame.origin.y = 20; - frame.size.height = CGRectGetHeight(self.view.bounds)-20; - } - else { - frame.origin.y = 0; - frame.size.height = CGRectGetHeight(self.view.bounds); - } - [self.childControllerContainerView setFrame:frame]; - [self.dummyStatusBarView setHidden:!showsDummyStatusBar]; - } -} - --(void)setStatusBarViewBackgroundColor:(UIColor *)dummyStatusBarColor{ - _statusBarViewBackgroundColor = dummyStatusBarColor; - [self.dummyStatusBarView setBackgroundColor:_statusBarViewBackgroundColor]; -} - --(void)setAnimatingDrawer:(BOOL)animatingDrawer{ - _animatingDrawer = animatingDrawer; - [self.view setUserInteractionEnabled:!animatingDrawer]; -} - -#pragma mark - Getters --(CGFloat)maximumLeftDrawerWidth{ - if(self.leftDrawerViewController){ - return _maximumLeftDrawerWidth; - } - else{ - return 0; - } -} - --(CGFloat)maximumRightDrawerWidth{ - if(self.rightDrawerViewController){ - return _maximumRightDrawerWidth; - } - else { - return 0; - } -} - --(CGFloat)visibleLeftDrawerWidth{ - return MAX(0.0,CGRectGetMinX(self.centerContainerView.frame)); -} - --(CGFloat)visibleRightDrawerWidth{ - if(CGRectGetMinX(self.centerContainerView.frame)<0){ - return CGRectGetWidth(self.childControllerContainerView.bounds)-CGRectGetMaxX(self.centerContainerView.frame); - } - else { - return 0.0f; - } -} - --(UIView*)childControllerContainerView{ - if(_childControllerContainerView == nil){ - //Issue #152 (https://github.com/mutualmobile/MMDrawerController/issues/152) - //Turns out we have two child container views getting added to the view during init, - //because the first request self.view.bounds was kicking off a viewDidLoad, which - //caused us to be able to fall through this check twice. - // - //The fix is to grab the bounds, and then check again that the child container view has - //not been created. - CGRect childContainerViewFrame = self.view.bounds; - if(_childControllerContainerView == nil){ - _childControllerContainerView = [[UIView alloc] initWithFrame:childContainerViewFrame]; - [_childControllerContainerView setBackgroundColor:[UIColor clearColor]]; - [_childControllerContainerView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; - [self.view addSubview:_childControllerContainerView]; - } - - } - return _childControllerContainerView; -} - --(UIView*)dummyStatusBarView{ - if(_dummyStatusBarView==nil){ - _dummyStatusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 20)]; - [_dummyStatusBarView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; - [_dummyStatusBarView setBackgroundColor:self.statusBarViewBackgroundColor]; - [_dummyStatusBarView setHidden:!_showsStatusBarBackgroundView]; - [self.view addSubview:_dummyStatusBarView]; - } - return _dummyStatusBarView; -} - --(UIColor*)statusBarViewBackgroundColor{ - if(_statusBarViewBackgroundColor == nil){ - _statusBarViewBackgroundColor = [UIColor blackColor]; - } - return _statusBarViewBackgroundColor; -} - -#pragma mark - Gesture Handlers - --(void)tapGestureCallback:(UITapGestureRecognizer *)tapGesture{ - if(self.openSide != MMDrawerSideNone && - self.isAnimatingDrawer == NO){ - [self closeDrawerAnimated:YES completion:^(BOOL finished) { - if(self.gestureCompletion){ - self.gestureCompletion(self, tapGesture); - } - }]; - } -} - --(void)panGestureCallback:(UIPanGestureRecognizer *)panGesture{ - switch (panGesture.state) { - case UIGestureRecognizerStateBegan:{ - if(self.animatingDrawer){ - [panGesture setEnabled:NO]; - break; - } - else { - self.startingPanRect = self.centerContainerView.frame; - } - } - case UIGestureRecognizerStateChanged:{ - self.view.userInteractionEnabled = NO; - CGRect newFrame = self.startingPanRect; - CGPoint translatedPoint = [panGesture translationInView:self.centerContainerView]; - newFrame.origin.x = [self roundedOriginXForDrawerConstriants:CGRectGetMinX(self.startingPanRect)+translatedPoint.x]; - newFrame = CGRectIntegral(newFrame); - CGFloat xOffset = newFrame.origin.x; - - MMDrawerSide visibleSide = MMDrawerSideNone; - CGFloat percentVisible = 0.0; - if(xOffset > 0){ - visibleSide = MMDrawerSideLeft; - percentVisible = xOffset/self.maximumLeftDrawerWidth; - } - else if(xOffset < 0){ - visibleSide = MMDrawerSideRight; - percentVisible = ABS(xOffset)/self.maximumRightDrawerWidth; - } - UIViewController * visibleSideDrawerViewController = [self sideDrawerViewControllerForSide:visibleSide]; - - if(self.openSide != visibleSide){ - //Handle disappearing the visible drawer - UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:self.openSide]; - [sideDrawerViewController beginAppearanceTransition:NO animated:NO]; - [sideDrawerViewController endAppearanceTransition]; - - //Drawer is about to become visible - [self prepareToPresentDrawer:visibleSide animated:NO]; - [visibleSideDrawerViewController endAppearanceTransition]; - [self setOpenSide:visibleSide]; - } - else if(visibleSide == MMDrawerSideNone){ - [self setOpenSide:MMDrawerSideNone]; - } - - [self updateDrawerVisualStateForDrawerSide:visibleSide percentVisible:percentVisible]; - - [self.centerContainerView setCenter:CGPointMake(CGRectGetMidX(newFrame), CGRectGetMidY(newFrame))]; - - newFrame = self.centerContainerView.frame; - newFrame.origin.x = floor(newFrame.origin.x); - newFrame.origin.y = floor(newFrame.origin.y); - self.centerContainerView.frame = newFrame; - - break; - } - case UIGestureRecognizerStateEnded: - case UIGestureRecognizerStateCancelled: { - self.startingPanRect = CGRectNull; - CGPoint velocity = [panGesture velocityInView:self.childControllerContainerView]; - [self finishAnimationForPanGestureWithXVelocity:velocity.x completion:^(BOOL finished) { - if(self.gestureCompletion){ - self.gestureCompletion(self, panGesture); - } - }]; - self.view.userInteractionEnabled = YES; - break; - } - default: - break; - } -} - -#pragma mark - iOS 7 Status Bar Helpers --(UIViewController*)childViewControllerForStatusBarStyle{ - return [self childViewControllerForSide:self.openSide]; -} - --(UIViewController*)childViewControllerForStatusBarHidden{ - return [self childViewControllerForSide:self.openSide]; -} - --(void)setNeedsStatusBarAppearanceUpdateIfSupported{ - if([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){ - [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; - } -} - -#pragma mark - iOS 8 Rotation Helpers -- (BOOL)needsManualForwardingOfRotationEvents{ - BOOL isIOS8 = (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1); - return !isIOS8; -} - -#pragma mark - Animation helpers --(void)finishAnimationForPanGestureWithXVelocity:(CGFloat)xVelocity completion:(void(^)(BOOL finished))completion{ - CGFloat currentOriginX = CGRectGetMinX(self.centerContainerView.frame); - - CGFloat animationVelocity = MAX(ABS(xVelocity),self.panVelocityXAnimationThreshold*2); - - if(self.openSide == MMDrawerSideLeft) { - CGFloat midPoint = self.maximumLeftDrawerWidth / 2.0; - if(xVelocity > self.panVelocityXAnimationThreshold){ - [self openDrawerSide:MMDrawerSideLeft animated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; - } - else if(xVelocity < -self.panVelocityXAnimationThreshold){ - [self closeDrawerAnimated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; - } - else if(currentOriginX < midPoint){ - [self closeDrawerAnimated:YES completion:completion]; - } - else { - [self openDrawerSide:MMDrawerSideLeft animated:YES completion:completion]; - } - } - else if(self.openSide == MMDrawerSideRight){ - currentOriginX = CGRectGetMaxX(self.centerContainerView.frame); - CGFloat midPoint = (CGRectGetWidth(self.childControllerContainerView.bounds)-self.maximumRightDrawerWidth) + (self.maximumRightDrawerWidth / 2.0); - if(xVelocity > self.panVelocityXAnimationThreshold){ - [self closeDrawerAnimated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; - } - else if (xVelocity < -self.panVelocityXAnimationThreshold){ - [self openDrawerSide:MMDrawerSideRight animated:YES velocity:animationVelocity animationOptions:UIViewAnimationOptionCurveEaseOut completion:completion]; - } - else if(currentOriginX > midPoint){ - [self closeDrawerAnimated:YES completion:completion]; - } - else { - [self openDrawerSide:MMDrawerSideRight animated:YES completion:completion]; - } - } - else { - if(completion){ - completion(NO); - } - } -} - --(void)updateDrawerVisualStateForDrawerSide:(MMDrawerSide)drawerSide percentVisible:(CGFloat)percentVisible{ - if(self.drawerVisualState){ - self.drawerVisualState(self,drawerSide,percentVisible); - } - else if(self.shouldStretchDrawer){ - [self applyOvershootScaleTransformForDrawerSide:drawerSide percentVisible:percentVisible]; - } -} - -- (void)applyOvershootScaleTransformForDrawerSide:(MMDrawerSide)drawerSide percentVisible:(CGFloat)percentVisible{ - - if (percentVisible >= 1.f) { - CATransform3D transform = CATransform3DIdentity; - UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; - if(drawerSide == MMDrawerSideLeft) { - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, self.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - else if(drawerSide == MMDrawerSideRight){ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, -self.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - sideDrawerViewController.view.layer.transform = transform; - } -} - --(void)resetDrawerVisualStateForDrawerSide:(MMDrawerSide)drawerSide{ - UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide]; - - [sideDrawerViewController.view.layer setAnchorPoint:CGPointMake(0.5f, 0.5f)]; - [sideDrawerViewController.view.layer setTransform:CATransform3DIdentity]; - [sideDrawerViewController.view setAlpha:1.0]; -} - --(CGFloat)roundedOriginXForDrawerConstriants:(CGFloat)originX{ - - if (originX < -self.maximumRightDrawerWidth) { - if (self.shouldStretchDrawer && - self.rightDrawerViewController) { - CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumRightDrawerWidth)*MMDrawerOvershootPercentage; - return originXForDrawerOriginAndTargetOriginOffset(originX, -self.maximumRightDrawerWidth, maxOvershoot); - } - else{ - return -self.maximumRightDrawerWidth; - } - } - else if(originX > self.maximumLeftDrawerWidth){ - if (self.shouldStretchDrawer && - self.leftDrawerViewController) { - CGFloat maxOvershoot = (CGRectGetWidth(self.centerContainerView.frame)-self.maximumLeftDrawerWidth)*MMDrawerOvershootPercentage; - return originXForDrawerOriginAndTargetOriginOffset(originX, self.maximumLeftDrawerWidth, maxOvershoot); - } - else{ - return self.maximumLeftDrawerWidth; - } - } - - return originX; -} - -static inline CGFloat originXForDrawerOriginAndTargetOriginOffset(CGFloat originX, CGFloat targetOffset, CGFloat maxOvershoot){ - CGFloat delta = ABS(originX - targetOffset); - CGFloat maxLinearPercentage = MMDrawerOvershootLinearRangePercentage; - CGFloat nonLinearRange = maxOvershoot * maxLinearPercentage; - CGFloat nonLinearScalingDelta = (delta - nonLinearRange); - CGFloat overshoot = nonLinearRange + nonLinearScalingDelta * nonLinearRange/sqrt(pow(nonLinearScalingDelta,2.f) + 15000); - - if (delta < nonLinearRange) { - return originX; - } - else if (targetOffset < 0) { - return targetOffset - round(overshoot); - } - else{ - return targetOffset + round(overshoot); - } -} - -#pragma mark - Helpers --(void)setupGestureRecognizers{ - UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureCallback:)]; - [pan setDelegate:self]; - [self.view addGestureRecognizer:pan]; - - UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureCallback:)]; - [tap setDelegate:self]; - [self.view addGestureRecognizer:tap]; -} - --(void)prepareToPresentDrawer:(MMDrawerSide)drawer animated:(BOOL)animated{ - MMDrawerSide drawerToHide = MMDrawerSideNone; - if(drawer == MMDrawerSideLeft){ - drawerToHide = MMDrawerSideRight; - } - else if(drawer == MMDrawerSideRight){ - drawerToHide = MMDrawerSideLeft; - } - - UIViewController * sideDrawerViewControllerToPresent = [self sideDrawerViewControllerForSide:drawer]; - UIViewController * sideDrawerViewControllerToHide = [self sideDrawerViewControllerForSide:drawerToHide]; - - [self.childControllerContainerView sendSubviewToBack:sideDrawerViewControllerToHide.view]; - [sideDrawerViewControllerToHide.view setHidden:YES]; - [sideDrawerViewControllerToPresent.view setHidden:NO]; - [self resetDrawerVisualStateForDrawerSide:drawer]; - [sideDrawerViewControllerToPresent.view setFrame:sideDrawerViewControllerToPresent.mm_visibleDrawerFrame]; - [self updateDrawerVisualStateForDrawerSide:drawer percentVisible:0.0]; - [sideDrawerViewControllerToPresent beginAppearanceTransition:YES animated:animated]; -} - --(void)updateShadowForCenterView{ - UIView * centerView = self.centerContainerView; - if(self.showsShadow){ - centerView.layer.masksToBounds = NO; - centerView.layer.shadowRadius = self.shadowRadius; - centerView.layer.shadowOpacity = self.shadowOpacity; - centerView.layer.shadowOffset = self.shadowOffset; - centerView.layer.shadowColor = [self.shadowColor CGColor]; - - /** In the event this gets called a lot, we won't update the shadowPath - unless it needs to be updated (like during rotation) */ - if (centerView.layer.shadowPath == NULL) { - centerView.layer.shadowPath = [[UIBezierPath bezierPathWithRect:self.centerContainerView.bounds] CGPath]; - } - else{ - CGRect currentPath = CGPathGetPathBoundingBox(centerView.layer.shadowPath); - if (CGRectEqualToRect(currentPath, centerView.bounds) == NO){ - centerView.layer.shadowPath = [[UIBezierPath bezierPathWithRect:self.centerContainerView.bounds] CGPath]; - } - } - } - else if (centerView.layer.shadowPath != NULL) { - centerView.layer.shadowRadius = 0.f; - centerView.layer.shadowOpacity = 0.f; - centerView.layer.shadowOffset = CGSizeMake(0, -3); - centerView.layer.shadowPath = NULL; - centerView.layer.masksToBounds = YES; - } -} - --(NSTimeInterval)animationDurationForAnimationDistance:(CGFloat)distance{ - NSTimeInterval duration = MAX(distance/self.animationVelocity,MMDrawerMinimumAnimationDuration); - return duration; -} - --(UIViewController*)sideDrawerViewControllerForSide:(MMDrawerSide)drawerSide{ - UIViewController * sideDrawerViewController = nil; - if(drawerSide != MMDrawerSideNone){ - sideDrawerViewController = [self childViewControllerForSide:drawerSide]; - } - return sideDrawerViewController; -} - --(UIViewController*)childViewControllerForSide:(MMDrawerSide)drawerSide{ - UIViewController * childViewController = nil; - switch (drawerSide) { - case MMDrawerSideLeft: - childViewController = self.leftDrawerViewController; - break; - case MMDrawerSideRight: - childViewController = self.rightDrawerViewController; - break; - case MMDrawerSideNone: - childViewController = self.centerViewController; - break; - } - return childViewController; -} - -#pragma mark - UIGestureRecognizerDelegate --(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ - - if(self.openSide == MMDrawerSideNone){ - MMOpenDrawerGestureMode possibleOpenGestureModes = [self possibleOpenGestureModesForGestureRecognizer:gestureRecognizer - withTouch:touch]; - return ((self.openDrawerGestureModeMask & possibleOpenGestureModes)>0); - } - else{ - MMCloseDrawerGestureMode possibleCloseGestureModes = [self possibleCloseGestureModesForGestureRecognizer:gestureRecognizer - withTouch:touch]; - return ((self.closeDrawerGestureModeMask & possibleCloseGestureModes)>0); - } -} - -#pragma mark Gesture Recogizner Delegate Helpers --(MMCloseDrawerGestureMode)possibleCloseGestureModesForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer withTouch:(UITouch*)touch{ - CGPoint point = [touch locationInView:self.childControllerContainerView]; - MMCloseDrawerGestureMode possibleCloseGestureModes = MMCloseDrawerGestureModeNone; - if([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]]){ - if([self isPointContainedWithinNavigationRect:point]){ - possibleCloseGestureModes |= MMCloseDrawerGestureModeTapNavigationBar; - } - if([self isPointContainedWithinCenterViewContentRect:point]){ - possibleCloseGestureModes |= MMCloseDrawerGestureModeTapCenterView; - } - } - else if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){ - if([self isPointContainedWithinNavigationRect:point]){ - possibleCloseGestureModes |= MMCloseDrawerGestureModePanningNavigationBar; - } - if([self isPointContainedWithinCenterViewContentRect:point]){ - possibleCloseGestureModes |= MMCloseDrawerGestureModePanningCenterView; - } - if([self isPointContainedWithinRightBezelRect:point] && - self.openSide == MMDrawerSideLeft){ - possibleCloseGestureModes |= MMCloseDrawerGestureModeBezelPanningCenterView; - } - if([self isPointContainedWithinLeftBezelRect:point] && - self.openSide == MMDrawerSideRight){ - possibleCloseGestureModes |= MMCloseDrawerGestureModeBezelPanningCenterView; - } - if([self isPointContainedWithinCenterViewContentRect:point] == NO && - [self isPointContainedWithinNavigationRect:point] == NO){ - possibleCloseGestureModes |= MMCloseDrawerGestureModePanningDrawerView; - } - } - if((self.closeDrawerGestureModeMask & MMCloseDrawerGestureModeCustom) > 0 && - self.gestureShouldRecognizeTouch){ - if(self.gestureShouldRecognizeTouch(self,gestureRecognizer,touch)){ - possibleCloseGestureModes |= MMCloseDrawerGestureModeCustom; - } - } - return possibleCloseGestureModes; -} - --(MMOpenDrawerGestureMode)possibleOpenGestureModesForGestureRecognizer:(UIGestureRecognizer*)gestureRecognizer withTouch:(UITouch*)touch{ - CGPoint point = [touch locationInView:self.childControllerContainerView]; - MMOpenDrawerGestureMode possibleOpenGestureModes = MMOpenDrawerGestureModeNone; - if([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]){ - if([self isPointContainedWithinNavigationRect:point]){ - possibleOpenGestureModes |= MMOpenDrawerGestureModePanningNavigationBar; - } - if([self isPointContainedWithinCenterViewContentRect:point]){ - possibleOpenGestureModes |= MMOpenDrawerGestureModePanningCenterView; - } - if([self isPointContainedWithinLeftBezelRect:point] && - self.leftDrawerViewController){ - possibleOpenGestureModes |= MMOpenDrawerGestureModeBezelPanningCenterView; - } - if([self isPointContainedWithinRightBezelRect:point] && - self.rightDrawerViewController){ - possibleOpenGestureModes |= MMOpenDrawerGestureModeBezelPanningCenterView; - } - } - if((self.openDrawerGestureModeMask & MMOpenDrawerGestureModeCustom) > 0 && - self.gestureShouldRecognizeTouch){ - if(self.gestureShouldRecognizeTouch(self,gestureRecognizer,touch)){ - possibleOpenGestureModes |= MMOpenDrawerGestureModeCustom; - } - } - return possibleOpenGestureModes; -} - --(BOOL)isPointContainedWithinNavigationRect:(CGPoint)point{ - CGRect navigationBarRect = CGRectNull; - if([self.centerViewController isKindOfClass:[UINavigationController class]]){ - UINavigationBar * navBar = [(UINavigationController*)self.centerViewController navigationBar]; - navigationBarRect = [navBar convertRect:navBar.bounds toView:self.childControllerContainerView]; - navigationBarRect = CGRectIntersection(navigationBarRect,self.childControllerContainerView.bounds); - } - return CGRectContainsPoint(navigationBarRect,point); -} - --(BOOL)isPointContainedWithinCenterViewContentRect:(CGPoint)point{ - CGRect centerViewContentRect = self.centerContainerView.frame; - centerViewContentRect = CGRectIntersection(centerViewContentRect,self.childControllerContainerView.bounds); - return (CGRectContainsPoint(centerViewContentRect, point) && - [self isPointContainedWithinNavigationRect:point] == NO); -} - --(BOOL)isPointContainedWithinLeftBezelRect:(CGPoint)point{ - CGRect leftBezelRect = CGRectNull; - CGRect tempRect; - CGRectDivide(self.childControllerContainerView.bounds, &leftBezelRect, &tempRect, self.bezelPanningCenterViewRange, CGRectMinXEdge); - return (CGRectContainsPoint(leftBezelRect, point) && - [self isPointContainedWithinCenterViewContentRect:point]); -} - --(BOOL)isPointContainedWithinRightBezelRect:(CGPoint)point{ - CGRect rightBezelRect = CGRectNull; - CGRect tempRect; - CGRectDivide(self.childControllerContainerView.bounds, &rightBezelRect, &tempRect, self.bezelPanningCenterViewRange, CGRectMaxXEdge); - - return (CGRectContainsPoint(rightBezelRect, point) && - [self isPointContainedWithinCenterViewContentRect:point]); -} -@end diff --git a/WBSBlog/Lib/MMDrawerController/MMDrawerVisualState.h b/WBSBlog/Lib/MMDrawerController/MMDrawerVisualState.h deleted file mode 100755 index 7cb8fff..0000000 --- a/WBSBlog/Lib/MMDrawerController/MMDrawerVisualState.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#import -#import "MMDrawerController.h" - -/** - `MMDrawerVisualState` provides prebuilt visual state update blocks that can be used in the callback block of `MMDrawerController` for drawer animation. - */ - -@interface MMDrawerVisualState : NSObject - -/** - Creates a slide and scale visual state block that gives an experience similar to Mailbox.app. It scales from 90% to 100%, and translates 50 pixels in the x direction. In addition, it also sets alpha from 0.0 to 1.0. - - @return The visual state block. - */ -+(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock; - -/** - Creates a slide visual state block that gives the user an experience that slides at the same speed of the center view controller during animation. This is equal to calling `parallaxVisualStateBlockWithParallaxFactor:` with a parallax factor of 1.0. - - @return The visual state block. - */ -+(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock; - -/** - Creates a swinging door visual state block that gives the user an experience that animates the drawer in along the hinge. - - @return The visual state block. - */ -+(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock; - -/** - Creates a parallax experience that slides the side drawer view controller at a different rate than the center view controller during animation. For every parallaxFactor of points moved by the center view controller, the side drawer view controller will move 1 point. Passing in 1.0 is the equivalent of a applying a sliding animation, while passing in MAX_FLOAT is the equivalent of having no animation at all. - - @param parallaxFactor The amount of parallax applied to the side drawer conroller. This value must be greater than 1.0. The closer the value is to 1.0, the faster the side drawer view controller will be parallaxing. - - @return The visual state block. - */ -+(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor; - -@end diff --git a/WBSBlog/Lib/MMDrawerController/MMDrawerVisualState.m b/WBSBlog/Lib/MMDrawerController/MMDrawerVisualState.m deleted file mode 100755 index 013d019..0000000 --- a/WBSBlog/Lib/MMDrawerController/MMDrawerVisualState.m +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#import "MMDrawerVisualState.h" -#import - -@implementation MMDrawerVisualState -+(MMDrawerControllerDrawerVisualStateBlock)slideAndScaleVisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - CGFloat minScale = .90; - CGFloat scale = minScale + (percentVisible*(1.0-minScale)); - CATransform3D scaleTransform = CATransform3DMakeScale(scale, scale, scale); - - CGFloat maxDistance = 50; - CGFloat distance = maxDistance * percentVisible; - CATransform3D translateTransform = CATransform3DIdentity; - UIViewController * sideDrawerViewController; - if(drawerSide == MMDrawerSideLeft) { - sideDrawerViewController = drawerController.leftDrawerViewController; - translateTransform = CATransform3DMakeTranslation((maxDistance-distance), 0.0, 0.0); - } - else if(drawerSide == MMDrawerSideRight){ - sideDrawerViewController = drawerController.rightDrawerViewController; - translateTransform = CATransform3DMakeTranslation(-(maxDistance-distance), 0.0, 0.0); - } - - [sideDrawerViewController.view.layer setTransform:CATransform3DConcat(scaleTransform, translateTransform)]; - [sideDrawerViewController.view setAlpha:percentVisible]; - }; - return visualStateBlock; -} - -+(MMDrawerControllerDrawerVisualStateBlock)slideVisualStateBlock{ - return [self parallaxVisualStateBlockWithParallaxFactor:1.0]; -} - - -+(MMDrawerControllerDrawerVisualStateBlock)swingingDoorVisualStateBlock{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - UIViewController * sideDrawerViewController; - CGPoint anchorPoint; - CGFloat maxDrawerWidth = 0.0; - CGFloat xOffset; - CGFloat angle = 0.0; - - if(drawerSide==MMDrawerSideLeft){ - - sideDrawerViewController = drawerController.leftDrawerViewController; - anchorPoint = CGPointMake(1.0, .5); - maxDrawerWidth = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); - xOffset = -(maxDrawerWidth/2.0) + (maxDrawerWidth)*percentVisible; - angle = -M_PI_2+(percentVisible*M_PI_2); - } - else { - sideDrawerViewController = drawerController.rightDrawerViewController; - anchorPoint = CGPointMake(0.0, .5); - maxDrawerWidth = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); - xOffset = (maxDrawerWidth/2.0) - (maxDrawerWidth)*percentVisible; - angle = M_PI_2-(percentVisible*M_PI_2); - } - - [sideDrawerViewController.view.layer setAnchorPoint:anchorPoint]; - [sideDrawerViewController.view.layer setShouldRasterize:YES]; - [sideDrawerViewController.view.layer setRasterizationScale:[[UIScreen mainScreen] scale]]; - - CATransform3D swingingDoorTransform = CATransform3DIdentity; - if (percentVisible <= 1.f) { - - CATransform3D identity = CATransform3DIdentity; - identity.m34 = -1.0/1000.0; - CATransform3D rotateTransform = CATransform3DRotate(identity, angle, 0.0, 1.0, 0.0); - - CATransform3D translateTransform = CATransform3DMakeTranslation(xOffset, 0.0, 0.0); - - CATransform3D concatTransform = CATransform3DConcat(rotateTransform, translateTransform); - - swingingDoorTransform = concatTransform; - } - else{ - CATransform3D overshootTransform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - - NSInteger scalingModifier = 1.f; - if (drawerSide == MMDrawerSideRight) { - scalingModifier = -1.f; - } - - overshootTransform = CATransform3DTranslate(overshootTransform, scalingModifier*maxDrawerWidth/2, 0.f, 0.f); - swingingDoorTransform = overshootTransform; - } - - [sideDrawerViewController.view.layer setTransform:swingingDoorTransform]; - }; - return visualStateBlock; -} - -+(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor{ - MMDrawerControllerDrawerVisualStateBlock visualStateBlock = - ^(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible){ - NSParameterAssert(parallaxFactor >= 1.0); - CATransform3D transform = CATransform3DIdentity; - UIViewController * sideDrawerViewController; - if(drawerSide == MMDrawerSideLeft) { - sideDrawerViewController = drawerController.leftDrawerViewController; - CGFloat distance = MAX(drawerController.maximumLeftDrawerWidth,drawerController.visibleLeftDrawerWidth); - if (percentVisible <= 1.f) { - transform = CATransform3DMakeTranslation((-distance)/parallaxFactor+(distance*percentVisible/parallaxFactor), 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, drawerController.maximumLeftDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - else if(drawerSide == MMDrawerSideRight){ - sideDrawerViewController = drawerController.rightDrawerViewController; - CGFloat distance = MAX(drawerController.maximumRightDrawerWidth,drawerController.visibleRightDrawerWidth); - if(percentVisible <= 1.f){ - transform = CATransform3DMakeTranslation((distance)/parallaxFactor-(distance*percentVisible)/parallaxFactor, 0.0, 0.0); - } - else{ - transform = CATransform3DMakeScale(percentVisible, 1.f, 1.f); - transform = CATransform3DTranslate(transform, -drawerController.maximumRightDrawerWidth*(percentVisible-1.f)/2, 0.f, 0.f); - } - } - - [sideDrawerViewController.view.layer setTransform:transform]; - }; - return visualStateBlock; -} - -@end diff --git a/WBSBlog/Lib/MMDrawerController/UIViewController+MMDrawerController.h b/WBSBlog/Lib/MMDrawerController/UIViewController+MMDrawerController.h deleted file mode 100755 index 1bf05ef..0000000 --- a/WBSBlog/Lib/MMDrawerController/UIViewController+MMDrawerController.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#import - -#import "MMDrawerController.h" - -/** - A helper category on `UIViewController` that exposes the parent drawer controller, the visible side drawer frame, and a `mm_drawerWillAppear` method that is called when the drawer is about to appear. - */ - -@interface UIViewController (MMDrawerController) - -///--------------------------------------- -/// @name Accessing Drawer View Controller Properties -///--------------------------------------- - -/** - The `MMDrawerController` that the view controller is contained within. If the view controller is not contained within a `MMDrawerController`, this property is nil. Note that if the view controller is contained within a `UINavigationController`, that navigation controller is contained within a `MMDrawerController`, this property will return a refernce to the `MMDrawerController`, despite the fact that it is not the direct parent of the view controller. - */ -@property(nonatomic, strong, readonly) MMDrawerController *mm_drawerController; - -/** - The visible rect of the side drawer view controller in the drawer controller coordinate space. If the view controller is not a drawer in a `MMDrawerController`, then this property returns `CGRectNull` - */ -@property(nonatomic, assign, readonly) CGRect mm_visibleDrawerFrame; - -@end diff --git a/WBSBlog/Lib/MMDrawerController/UIViewController+MMDrawerController.m b/WBSBlog/Lib/MMDrawerController/UIViewController+MMDrawerController.m deleted file mode 100755 index b1f8662..0000000 --- a/WBSBlog/Lib/MMDrawerController/UIViewController+MMDrawerController.m +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2013 Mutual Mobile (http://mutualmobile.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -#import "UIViewController+MMDrawerController.h" - -@implementation UIViewController (MMDrawerController) - - --(MMDrawerController*)mm_drawerController{ - UIViewController *parentViewController = self.parentViewController; - while (parentViewController != nil) { - if([parentViewController isKindOfClass:[MMDrawerController class]]){ - return (MMDrawerController *)parentViewController; - } - parentViewController = parentViewController.parentViewController; - } - return nil; -} - --(CGRect)mm_visibleDrawerFrame{ - if([self isEqual:self.mm_drawerController.leftDrawerViewController] || - [self.navigationController isEqual:self.mm_drawerController.leftDrawerViewController]){ - CGRect rect = self.mm_drawerController.view.bounds; - rect.size.width = self.mm_drawerController.maximumLeftDrawerWidth; - if (self.mm_drawerController.showsStatusBarBackgroundView) { - rect.size.height -= 20.0f; - } - return rect; - - } - else if([self isEqual:self.mm_drawerController.rightDrawerViewController] || - [self.navigationController isEqual:self.mm_drawerController.rightDrawerViewController]){ - CGRect rect = self.mm_drawerController.view.bounds; - rect.size.width = self.mm_drawerController.maximumRightDrawerWidth; - rect.origin.x = CGRectGetWidth(self.mm_drawerController.view.bounds)-rect.size.width; - if (self.mm_drawerController.showsStatusBarBackgroundView) { - rect.size.height -= 20.0f; - } - return rect; - } - else { - return CGRectNull; - } -} - -@end