├── .gitignore ├── Example ├── FlowingMenuExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── FlowingMenuExample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── MainTableViewController.h │ ├── MainTableViewController.m │ ├── MenuTableViewController.h │ ├── MenuTableViewController.m │ ├── Source-oc │ │ ├── FlowingMenuTransitionManager.h │ │ ├── FlowingMenuTransitionManager.m │ │ ├── FlowingMenuTransitionStatus.h │ │ ├── FlowingMenuTransitionStatus.m │ │ ├── FromViewControllerNeedsConform.h │ │ └── ToViewControllerNeedsConform.h │ └── main.m ├── FlowingMenuExampleTests │ ├── FlowingMenuExampleTests.m │ └── Info.plist └── FlowingMenuExampleUITests │ ├── FlowingMenuExampleUITests.m │ └── Info.plist ├── LICENSE ├── README.md ├── Source ├── FlowingMenuTransitionManager.h ├── FlowingMenuTransitionManager.m ├── FlowingMenuTransitionStatus.h ├── FlowingMenuTransitionStatus.m ├── FromViewControllerNeedsConform.h └── ToViewControllerNeedsConform.h └── YLFlowingMenu.podspec /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | Carthage/* 20 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1FA9C4AF1E9F7E57002EF1EE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4AE1E9F7E57002EF1EE /* main.m */; }; 11 | 1FA9C4B21E9F7E57002EF1EE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4B11E9F7E57002EF1EE /* AppDelegate.m */; }; 12 | 1FA9C4B81E9F7E57002EF1EE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1FA9C4B61E9F7E57002EF1EE /* Main.storyboard */; }; 13 | 1FA9C4BA1E9F7E57002EF1EE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1FA9C4B91E9F7E57002EF1EE /* Assets.xcassets */; }; 14 | 1FA9C4BD1E9F7E57002EF1EE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1FA9C4BB1E9F7E57002EF1EE /* LaunchScreen.storyboard */; }; 15 | 1FA9C4C81E9F7E57002EF1EE /* FlowingMenuExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4C71E9F7E57002EF1EE /* FlowingMenuExampleTests.m */; }; 16 | 1FA9C4D31E9F7E57002EF1EE /* FlowingMenuExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4D21E9F7E57002EF1EE /* FlowingMenuExampleUITests.m */; }; 17 | 1FA9C4ED1E9F7E64002EF1EE /* FlowingMenuTransitionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4E21E9F7E64002EF1EE /* FlowingMenuTransitionManager.m */; }; 18 | 1FA9C4EE1E9F7E64002EF1EE /* FlowingMenuTransitionStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4E41E9F7E64002EF1EE /* FlowingMenuTransitionStatus.m */; }; 19 | 1FA9C4F61E9F7EDB002EF1EE /* MainTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4F31E9F7EDB002EF1EE /* MainTableViewController.m */; }; 20 | 1FA9C4F71E9F7EDB002EF1EE /* MenuTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FA9C4F51E9F7EDB002EF1EE /* MenuTableViewController.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 1FA9C4C41E9F7E57002EF1EE /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 1FA9C4A21E9F7E57002EF1EE /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 1FA9C4A91E9F7E57002EF1EE; 29 | remoteInfo = FlowingMenuExample; 30 | }; 31 | 1FA9C4CF1E9F7E57002EF1EE /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = 1FA9C4A21E9F7E57002EF1EE /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = 1FA9C4A91E9F7E57002EF1EE; 36 | remoteInfo = FlowingMenuExample; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 1FA9C4AA1E9F7E57002EF1EE /* FlowingMenuExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FlowingMenuExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 1FA9C4AE1E9F7E57002EF1EE /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 43 | 1FA9C4B01E9F7E57002EF1EE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | 1FA9C4B11E9F7E57002EF1EE /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | 1FA9C4B71E9F7E57002EF1EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 1FA9C4B91E9F7E57002EF1EE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 1FA9C4BC1E9F7E57002EF1EE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 1FA9C4BE1E9F7E57002EF1EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 1FA9C4C31E9F7E57002EF1EE /* FlowingMenuExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FlowingMenuExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 1FA9C4C71E9F7E57002EF1EE /* FlowingMenuExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlowingMenuExampleTests.m; sourceTree = ""; }; 51 | 1FA9C4C91E9F7E57002EF1EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 1FA9C4CE1E9F7E57002EF1EE /* FlowingMenuExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FlowingMenuExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 1FA9C4D21E9F7E57002EF1EE /* FlowingMenuExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlowingMenuExampleUITests.m; sourceTree = ""; }; 54 | 1FA9C4D41E9F7E57002EF1EE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 1FA9C4E11E9F7E64002EF1EE /* FlowingMenuTransitionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlowingMenuTransitionManager.h; sourceTree = ""; }; 56 | 1FA9C4E21E9F7E64002EF1EE /* FlowingMenuTransitionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlowingMenuTransitionManager.m; sourceTree = ""; }; 57 | 1FA9C4E31E9F7E64002EF1EE /* FlowingMenuTransitionStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlowingMenuTransitionStatus.h; sourceTree = ""; }; 58 | 1FA9C4E41E9F7E64002EF1EE /* FlowingMenuTransitionStatus.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlowingMenuTransitionStatus.m; sourceTree = ""; }; 59 | 1FA9C4E51E9F7E64002EF1EE /* FromViewControllerNeedsConform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FromViewControllerNeedsConform.h; sourceTree = ""; }; 60 | 1FA9C4EC1E9F7E64002EF1EE /* ToViewControllerNeedsConform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ToViewControllerNeedsConform.h; sourceTree = ""; }; 61 | 1FA9C4F21E9F7EDB002EF1EE /* MainTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainTableViewController.h; sourceTree = ""; }; 62 | 1FA9C4F31E9F7EDB002EF1EE /* MainTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainTableViewController.m; sourceTree = ""; }; 63 | 1FA9C4F41E9F7EDB002EF1EE /* MenuTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuTableViewController.h; sourceTree = ""; }; 64 | 1FA9C4F51E9F7EDB002EF1EE /* MenuTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuTableViewController.m; sourceTree = ""; }; 65 | /* End PBXFileReference section */ 66 | 67 | /* Begin PBXFrameworksBuildPhase section */ 68 | 1FA9C4A71E9F7E57002EF1EE /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | ); 73 | runOnlyForDeploymentPostprocessing = 0; 74 | }; 75 | 1FA9C4C01E9F7E57002EF1EE /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | 1FA9C4CB1E9F7E57002EF1EE /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXFrameworksBuildPhase section */ 90 | 91 | /* Begin PBXGroup section */ 92 | 1FA9C4A11E9F7E57002EF1EE = { 93 | isa = PBXGroup; 94 | children = ( 95 | 1FA9C4AC1E9F7E57002EF1EE /* FlowingMenuExample */, 96 | 1FA9C4C61E9F7E57002EF1EE /* FlowingMenuExampleTests */, 97 | 1FA9C4D11E9F7E57002EF1EE /* FlowingMenuExampleUITests */, 98 | 1FA9C4AB1E9F7E57002EF1EE /* Products */, 99 | ); 100 | sourceTree = ""; 101 | }; 102 | 1FA9C4AB1E9F7E57002EF1EE /* Products */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 1FA9C4AA1E9F7E57002EF1EE /* FlowingMenuExample.app */, 106 | 1FA9C4C31E9F7E57002EF1EE /* FlowingMenuExampleTests.xctest */, 107 | 1FA9C4CE1E9F7E57002EF1EE /* FlowingMenuExampleUITests.xctest */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | 1FA9C4AC1E9F7E57002EF1EE /* FlowingMenuExample */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 1FA9C4E01E9F7E64002EF1EE /* Source-oc */, 116 | 1FA9C4B01E9F7E57002EF1EE /* AppDelegate.h */, 117 | 1FA9C4B11E9F7E57002EF1EE /* AppDelegate.m */, 118 | 1FA9C4F21E9F7EDB002EF1EE /* MainTableViewController.h */, 119 | 1FA9C4F31E9F7EDB002EF1EE /* MainTableViewController.m */, 120 | 1FA9C4F41E9F7EDB002EF1EE /* MenuTableViewController.h */, 121 | 1FA9C4F51E9F7EDB002EF1EE /* MenuTableViewController.m */, 122 | 1FA9C4B61E9F7E57002EF1EE /* Main.storyboard */, 123 | 1FA9C4B91E9F7E57002EF1EE /* Assets.xcassets */, 124 | 1FA9C4BB1E9F7E57002EF1EE /* LaunchScreen.storyboard */, 125 | 1FA9C4BE1E9F7E57002EF1EE /* Info.plist */, 126 | 1FA9C4AD1E9F7E57002EF1EE /* Supporting Files */, 127 | ); 128 | path = FlowingMenuExample; 129 | sourceTree = ""; 130 | }; 131 | 1FA9C4AD1E9F7E57002EF1EE /* Supporting Files */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 1FA9C4AE1E9F7E57002EF1EE /* main.m */, 135 | ); 136 | name = "Supporting Files"; 137 | sourceTree = ""; 138 | }; 139 | 1FA9C4C61E9F7E57002EF1EE /* FlowingMenuExampleTests */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 1FA9C4C71E9F7E57002EF1EE /* FlowingMenuExampleTests.m */, 143 | 1FA9C4C91E9F7E57002EF1EE /* Info.plist */, 144 | ); 145 | path = FlowingMenuExampleTests; 146 | sourceTree = ""; 147 | }; 148 | 1FA9C4D11E9F7E57002EF1EE /* FlowingMenuExampleUITests */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | 1FA9C4D21E9F7E57002EF1EE /* FlowingMenuExampleUITests.m */, 152 | 1FA9C4D41E9F7E57002EF1EE /* Info.plist */, 153 | ); 154 | path = FlowingMenuExampleUITests; 155 | sourceTree = ""; 156 | }; 157 | 1FA9C4E01E9F7E64002EF1EE /* Source-oc */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 1FA9C4E11E9F7E64002EF1EE /* FlowingMenuTransitionManager.h */, 161 | 1FA9C4E21E9F7E64002EF1EE /* FlowingMenuTransitionManager.m */, 162 | 1FA9C4E31E9F7E64002EF1EE /* FlowingMenuTransitionStatus.h */, 163 | 1FA9C4E41E9F7E64002EF1EE /* FlowingMenuTransitionStatus.m */, 164 | 1FA9C4E51E9F7E64002EF1EE /* FromViewControllerNeedsConform.h */, 165 | 1FA9C4EC1E9F7E64002EF1EE /* ToViewControllerNeedsConform.h */, 166 | ); 167 | path = "Source-oc"; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXGroup section */ 171 | 172 | /* Begin PBXNativeTarget section */ 173 | 1FA9C4A91E9F7E57002EF1EE /* FlowingMenuExample */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = 1FA9C4D71E9F7E57002EF1EE /* Build configuration list for PBXNativeTarget "FlowingMenuExample" */; 176 | buildPhases = ( 177 | 1FA9C4A61E9F7E57002EF1EE /* Sources */, 178 | 1FA9C4A71E9F7E57002EF1EE /* Frameworks */, 179 | 1FA9C4A81E9F7E57002EF1EE /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ); 185 | name = FlowingMenuExample; 186 | productName = FlowingMenuExample; 187 | productReference = 1FA9C4AA1E9F7E57002EF1EE /* FlowingMenuExample.app */; 188 | productType = "com.apple.product-type.application"; 189 | }; 190 | 1FA9C4C21E9F7E57002EF1EE /* FlowingMenuExampleTests */ = { 191 | isa = PBXNativeTarget; 192 | buildConfigurationList = 1FA9C4DA1E9F7E57002EF1EE /* Build configuration list for PBXNativeTarget "FlowingMenuExampleTests" */; 193 | buildPhases = ( 194 | 1FA9C4BF1E9F7E57002EF1EE /* Sources */, 195 | 1FA9C4C01E9F7E57002EF1EE /* Frameworks */, 196 | 1FA9C4C11E9F7E57002EF1EE /* Resources */, 197 | ); 198 | buildRules = ( 199 | ); 200 | dependencies = ( 201 | 1FA9C4C51E9F7E57002EF1EE /* PBXTargetDependency */, 202 | ); 203 | name = FlowingMenuExampleTests; 204 | productName = FlowingMenuExampleTests; 205 | productReference = 1FA9C4C31E9F7E57002EF1EE /* FlowingMenuExampleTests.xctest */; 206 | productType = "com.apple.product-type.bundle.unit-test"; 207 | }; 208 | 1FA9C4CD1E9F7E57002EF1EE /* FlowingMenuExampleUITests */ = { 209 | isa = PBXNativeTarget; 210 | buildConfigurationList = 1FA9C4DD1E9F7E57002EF1EE /* Build configuration list for PBXNativeTarget "FlowingMenuExampleUITests" */; 211 | buildPhases = ( 212 | 1FA9C4CA1E9F7E57002EF1EE /* Sources */, 213 | 1FA9C4CB1E9F7E57002EF1EE /* Frameworks */, 214 | 1FA9C4CC1E9F7E57002EF1EE /* Resources */, 215 | ); 216 | buildRules = ( 217 | ); 218 | dependencies = ( 219 | 1FA9C4D01E9F7E57002EF1EE /* PBXTargetDependency */, 220 | ); 221 | name = FlowingMenuExampleUITests; 222 | productName = FlowingMenuExampleUITests; 223 | productReference = 1FA9C4CE1E9F7E57002EF1EE /* FlowingMenuExampleUITests.xctest */; 224 | productType = "com.apple.product-type.bundle.ui-testing"; 225 | }; 226 | /* End PBXNativeTarget section */ 227 | 228 | /* Begin PBXProject section */ 229 | 1FA9C4A21E9F7E57002EF1EE /* Project object */ = { 230 | isa = PBXProject; 231 | attributes = { 232 | LastUpgradeCheck = 0830; 233 | ORGANIZATIONNAME = cheaterhu; 234 | TargetAttributes = { 235 | 1FA9C4A91E9F7E57002EF1EE = { 236 | CreatedOnToolsVersion = 8.3; 237 | ProvisioningStyle = Automatic; 238 | }; 239 | 1FA9C4C21E9F7E57002EF1EE = { 240 | CreatedOnToolsVersion = 8.3; 241 | ProvisioningStyle = Automatic; 242 | TestTargetID = 1FA9C4A91E9F7E57002EF1EE; 243 | }; 244 | 1FA9C4CD1E9F7E57002EF1EE = { 245 | CreatedOnToolsVersion = 8.3; 246 | ProvisioningStyle = Automatic; 247 | TestTargetID = 1FA9C4A91E9F7E57002EF1EE; 248 | }; 249 | }; 250 | }; 251 | buildConfigurationList = 1FA9C4A51E9F7E57002EF1EE /* Build configuration list for PBXProject "FlowingMenuExample" */; 252 | compatibilityVersion = "Xcode 3.2"; 253 | developmentRegion = English; 254 | hasScannedForEncodings = 0; 255 | knownRegions = ( 256 | en, 257 | Base, 258 | ); 259 | mainGroup = 1FA9C4A11E9F7E57002EF1EE; 260 | productRefGroup = 1FA9C4AB1E9F7E57002EF1EE /* Products */; 261 | projectDirPath = ""; 262 | projectRoot = ""; 263 | targets = ( 264 | 1FA9C4A91E9F7E57002EF1EE /* FlowingMenuExample */, 265 | 1FA9C4C21E9F7E57002EF1EE /* FlowingMenuExampleTests */, 266 | 1FA9C4CD1E9F7E57002EF1EE /* FlowingMenuExampleUITests */, 267 | ); 268 | }; 269 | /* End PBXProject section */ 270 | 271 | /* Begin PBXResourcesBuildPhase section */ 272 | 1FA9C4A81E9F7E57002EF1EE /* Resources */ = { 273 | isa = PBXResourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | 1FA9C4BD1E9F7E57002EF1EE /* LaunchScreen.storyboard in Resources */, 277 | 1FA9C4BA1E9F7E57002EF1EE /* Assets.xcassets in Resources */, 278 | 1FA9C4B81E9F7E57002EF1EE /* Main.storyboard in Resources */, 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | 1FA9C4C11E9F7E57002EF1EE /* Resources */ = { 283 | isa = PBXResourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | 1FA9C4CC1E9F7E57002EF1EE /* Resources */ = { 290 | isa = PBXResourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | /* End PBXResourcesBuildPhase section */ 297 | 298 | /* Begin PBXSourcesBuildPhase section */ 299 | 1FA9C4A61E9F7E57002EF1EE /* Sources */ = { 300 | isa = PBXSourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | 1FA9C4EE1E9F7E64002EF1EE /* FlowingMenuTransitionStatus.m in Sources */, 304 | 1FA9C4F61E9F7EDB002EF1EE /* MainTableViewController.m in Sources */, 305 | 1FA9C4B21E9F7E57002EF1EE /* AppDelegate.m in Sources */, 306 | 1FA9C4ED1E9F7E64002EF1EE /* FlowingMenuTransitionManager.m in Sources */, 307 | 1FA9C4F71E9F7EDB002EF1EE /* MenuTableViewController.m in Sources */, 308 | 1FA9C4AF1E9F7E57002EF1EE /* main.m in Sources */, 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | }; 312 | 1FA9C4BF1E9F7E57002EF1EE /* Sources */ = { 313 | isa = PBXSourcesBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | 1FA9C4C81E9F7E57002EF1EE /* FlowingMenuExampleTests.m in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | 1FA9C4CA1E9F7E57002EF1EE /* Sources */ = { 321 | isa = PBXSourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | 1FA9C4D31E9F7E57002EF1EE /* FlowingMenuExampleUITests.m in Sources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | /* End PBXSourcesBuildPhase section */ 329 | 330 | /* Begin PBXTargetDependency section */ 331 | 1FA9C4C51E9F7E57002EF1EE /* PBXTargetDependency */ = { 332 | isa = PBXTargetDependency; 333 | target = 1FA9C4A91E9F7E57002EF1EE /* FlowingMenuExample */; 334 | targetProxy = 1FA9C4C41E9F7E57002EF1EE /* PBXContainerItemProxy */; 335 | }; 336 | 1FA9C4D01E9F7E57002EF1EE /* PBXTargetDependency */ = { 337 | isa = PBXTargetDependency; 338 | target = 1FA9C4A91E9F7E57002EF1EE /* FlowingMenuExample */; 339 | targetProxy = 1FA9C4CF1E9F7E57002EF1EE /* PBXContainerItemProxy */; 340 | }; 341 | /* End PBXTargetDependency section */ 342 | 343 | /* Begin PBXVariantGroup section */ 344 | 1FA9C4B61E9F7E57002EF1EE /* Main.storyboard */ = { 345 | isa = PBXVariantGroup; 346 | children = ( 347 | 1FA9C4B71E9F7E57002EF1EE /* Base */, 348 | ); 349 | name = Main.storyboard; 350 | sourceTree = ""; 351 | }; 352 | 1FA9C4BB1E9F7E57002EF1EE /* LaunchScreen.storyboard */ = { 353 | isa = PBXVariantGroup; 354 | children = ( 355 | 1FA9C4BC1E9F7E57002EF1EE /* Base */, 356 | ); 357 | name = LaunchScreen.storyboard; 358 | sourceTree = ""; 359 | }; 360 | /* End PBXVariantGroup section */ 361 | 362 | /* Begin XCBuildConfiguration section */ 363 | 1FA9C4D51E9F7E57002EF1EE /* Debug */ = { 364 | isa = XCBuildConfiguration; 365 | buildSettings = { 366 | ALWAYS_SEARCH_USER_PATHS = NO; 367 | CLANG_ANALYZER_NONNULL = YES; 368 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 369 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 370 | CLANG_CXX_LIBRARY = "libc++"; 371 | CLANG_ENABLE_MODULES = YES; 372 | CLANG_ENABLE_OBJC_ARC = YES; 373 | CLANG_WARN_BOOL_CONVERSION = YES; 374 | CLANG_WARN_CONSTANT_CONVERSION = YES; 375 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 376 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 377 | CLANG_WARN_EMPTY_BODY = YES; 378 | CLANG_WARN_ENUM_CONVERSION = YES; 379 | CLANG_WARN_INFINITE_RECURSION = YES; 380 | CLANG_WARN_INT_CONVERSION = YES; 381 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 382 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 383 | CLANG_WARN_UNREACHABLE_CODE = YES; 384 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 385 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 386 | COPY_PHASE_STRIP = NO; 387 | DEBUG_INFORMATION_FORMAT = dwarf; 388 | ENABLE_STRICT_OBJC_MSGSEND = YES; 389 | ENABLE_TESTABILITY = YES; 390 | GCC_C_LANGUAGE_STANDARD = gnu99; 391 | GCC_DYNAMIC_NO_PIC = NO; 392 | GCC_NO_COMMON_BLOCKS = YES; 393 | GCC_OPTIMIZATION_LEVEL = 0; 394 | GCC_PREPROCESSOR_DEFINITIONS = ( 395 | "DEBUG=1", 396 | "$(inherited)", 397 | ); 398 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 399 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 400 | GCC_WARN_UNDECLARED_SELECTOR = YES; 401 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 402 | GCC_WARN_UNUSED_FUNCTION = YES; 403 | GCC_WARN_UNUSED_VARIABLE = YES; 404 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 405 | MTL_ENABLE_DEBUG_INFO = YES; 406 | ONLY_ACTIVE_ARCH = YES; 407 | SDKROOT = iphoneos; 408 | }; 409 | name = Debug; 410 | }; 411 | 1FA9C4D61E9F7E57002EF1EE /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ALWAYS_SEARCH_USER_PATHS = NO; 415 | CLANG_ANALYZER_NONNULL = YES; 416 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 417 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 418 | CLANG_CXX_LIBRARY = "libc++"; 419 | CLANG_ENABLE_MODULES = YES; 420 | CLANG_ENABLE_OBJC_ARC = YES; 421 | CLANG_WARN_BOOL_CONVERSION = YES; 422 | CLANG_WARN_CONSTANT_CONVERSION = YES; 423 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 424 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 425 | CLANG_WARN_EMPTY_BODY = YES; 426 | CLANG_WARN_ENUM_CONVERSION = YES; 427 | CLANG_WARN_INFINITE_RECURSION = YES; 428 | CLANG_WARN_INT_CONVERSION = YES; 429 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 430 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 431 | CLANG_WARN_UNREACHABLE_CODE = YES; 432 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 433 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 434 | COPY_PHASE_STRIP = NO; 435 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 436 | ENABLE_NS_ASSERTIONS = NO; 437 | ENABLE_STRICT_OBJC_MSGSEND = YES; 438 | GCC_C_LANGUAGE_STANDARD = gnu99; 439 | GCC_NO_COMMON_BLOCKS = YES; 440 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 441 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 442 | GCC_WARN_UNDECLARED_SELECTOR = YES; 443 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 444 | GCC_WARN_UNUSED_FUNCTION = YES; 445 | GCC_WARN_UNUSED_VARIABLE = YES; 446 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 447 | MTL_ENABLE_DEBUG_INFO = NO; 448 | SDKROOT = iphoneos; 449 | VALIDATE_PRODUCT = YES; 450 | }; 451 | name = Release; 452 | }; 453 | 1FA9C4D81E9F7E57002EF1EE /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 457 | INFOPLIST_FILE = FlowingMenuExample/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 459 | PRODUCT_BUNDLE_IDENTIFIER = hcd.FlowingMenuExample; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | TARGETED_DEVICE_FAMILY = "1,2"; 462 | }; 463 | name = Debug; 464 | }; 465 | 1FA9C4D91E9F7E57002EF1EE /* Release */ = { 466 | isa = XCBuildConfiguration; 467 | buildSettings = { 468 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 469 | INFOPLIST_FILE = FlowingMenuExample/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 471 | PRODUCT_BUNDLE_IDENTIFIER = hcd.FlowingMenuExample; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | TARGETED_DEVICE_FAMILY = "1,2"; 474 | }; 475 | name = Release; 476 | }; 477 | 1FA9C4DB1E9F7E57002EF1EE /* Debug */ = { 478 | isa = XCBuildConfiguration; 479 | buildSettings = { 480 | BUNDLE_LOADER = "$(TEST_HOST)"; 481 | INFOPLIST_FILE = FlowingMenuExampleTests/Info.plist; 482 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 483 | PRODUCT_BUNDLE_IDENTIFIER = hcd.FlowingMenuExampleTests; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FlowingMenuExample.app/FlowingMenuExample"; 486 | }; 487 | name = Debug; 488 | }; 489 | 1FA9C4DC1E9F7E57002EF1EE /* Release */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | BUNDLE_LOADER = "$(TEST_HOST)"; 493 | INFOPLIST_FILE = FlowingMenuExampleTests/Info.plist; 494 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 495 | PRODUCT_BUNDLE_IDENTIFIER = hcd.FlowingMenuExampleTests; 496 | PRODUCT_NAME = "$(TARGET_NAME)"; 497 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FlowingMenuExample.app/FlowingMenuExample"; 498 | }; 499 | name = Release; 500 | }; 501 | 1FA9C4DE1E9F7E57002EF1EE /* Debug */ = { 502 | isa = XCBuildConfiguration; 503 | buildSettings = { 504 | INFOPLIST_FILE = FlowingMenuExampleUITests/Info.plist; 505 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 506 | PRODUCT_BUNDLE_IDENTIFIER = hcd.FlowingMenuExampleUITests; 507 | PRODUCT_NAME = "$(TARGET_NAME)"; 508 | TEST_TARGET_NAME = FlowingMenuExample; 509 | }; 510 | name = Debug; 511 | }; 512 | 1FA9C4DF1E9F7E57002EF1EE /* Release */ = { 513 | isa = XCBuildConfiguration; 514 | buildSettings = { 515 | INFOPLIST_FILE = FlowingMenuExampleUITests/Info.plist; 516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 517 | PRODUCT_BUNDLE_IDENTIFIER = hcd.FlowingMenuExampleUITests; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | TEST_TARGET_NAME = FlowingMenuExample; 520 | }; 521 | name = Release; 522 | }; 523 | /* End XCBuildConfiguration section */ 524 | 525 | /* Begin XCConfigurationList section */ 526 | 1FA9C4A51E9F7E57002EF1EE /* Build configuration list for PBXProject "FlowingMenuExample" */ = { 527 | isa = XCConfigurationList; 528 | buildConfigurations = ( 529 | 1FA9C4D51E9F7E57002EF1EE /* Debug */, 530 | 1FA9C4D61E9F7E57002EF1EE /* Release */, 531 | ); 532 | defaultConfigurationIsVisible = 0; 533 | defaultConfigurationName = Release; 534 | }; 535 | 1FA9C4D71E9F7E57002EF1EE /* Build configuration list for PBXNativeTarget "FlowingMenuExample" */ = { 536 | isa = XCConfigurationList; 537 | buildConfigurations = ( 538 | 1FA9C4D81E9F7E57002EF1EE /* Debug */, 539 | 1FA9C4D91E9F7E57002EF1EE /* Release */, 540 | ); 541 | defaultConfigurationIsVisible = 0; 542 | defaultConfigurationName = Release; 543 | }; 544 | 1FA9C4DA1E9F7E57002EF1EE /* Build configuration list for PBXNativeTarget "FlowingMenuExampleTests" */ = { 545 | isa = XCConfigurationList; 546 | buildConfigurations = ( 547 | 1FA9C4DB1E9F7E57002EF1EE /* Debug */, 548 | 1FA9C4DC1E9F7E57002EF1EE /* Release */, 549 | ); 550 | defaultConfigurationIsVisible = 0; 551 | defaultConfigurationName = Release; 552 | }; 553 | 1FA9C4DD1E9F7E57002EF1EE /* Build configuration list for PBXNativeTarget "FlowingMenuExampleUITests" */ = { 554 | isa = XCConfigurationList; 555 | buildConfigurations = ( 556 | 1FA9C4DE1E9F7E57002EF1EE /* Debug */, 557 | 1FA9C4DF1E9F7E57002EF1EE /* Release */, 558 | ); 559 | defaultConfigurationIsVisible = 0; 560 | defaultConfigurationName = Release; 561 | }; 562 | /* End XCConfigurationList section */ 563 | }; 564 | rootObject = 1FA9C4A21E9F7E57002EF1EE /* Project object */; 565 | } 566 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // FlowingMenuExample 4 | // 5 | // Created by cheaterhu on 2017/4/13. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // FlowingMenuExample 4 | // 5 | // Created by cheaterhu on 2017/4/13. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/MainTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainTableViewController.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MainTableViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/MainTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainTableViewController.m 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import "MainTableViewController.h" 10 | #import "FlowingMenuTransitionManager.h" 11 | #import "FromViewControllerNeedsConform.h" 12 | 13 | @interface MainTableViewController () 14 | @property(strong, nonatomic) FlowingMenuTransitionManager *manager; 15 | @end 16 | 17 | @implementation MainTableViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | self.manager = [FlowingMenuTransitionManager manager]; 22 | [self.manager setInteractivePresentationView:self.view]; 23 | self.manager.fromVCDelegate = self; 24 | } 25 | 26 | -(UIColor *)colorOfElasticShapeInFlowingMenu:(UIView *)menuView 27 | { 28 | return [UIColor cyanColor]; 29 | } 30 | - (void)flowingMenuNeedsPresentMenu 31 | { 32 | [self presentViewController:[[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"menu"] animated:YES completion:nil]; 33 | } 34 | 35 | #pragma mark - Table view data source 36 | 37 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 38 | 39 | return 1; 40 | } 41 | 42 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 43 | 44 | return 20; 45 | } 46 | 47 | 48 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 49 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" ]; 50 | 51 | if (!cell) { 52 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"reuseIdentifier"]; 53 | } 54 | cell.textLabel.text = [NSString stringWithFormat:@"main view this is %li row",indexPath.row]; 55 | 56 | return cell; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/MenuTableViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuTableViewController.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MenuTableViewController : UITableViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/MenuTableViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuTableViewController.m 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import "MenuTableViewController.h" 10 | #import "ToViewControllerNeedsConform.h" 11 | #import "FlowingMenuTransitionManager.h" 12 | 13 | @interface MenuTableViewController () 14 | @property(strong, nonatomic) FlowingMenuTransitionManager *manager; 15 | @end 16 | 17 | @implementation MenuTableViewController 18 | 19 | - (void)viewDidLoad { 20 | [super viewDidLoad]; 21 | 22 | self.manager = [FlowingMenuTransitionManager manager]; 23 | self.transitioningDelegate = self.manager; 24 | self.manager.toVCDelegate = self; 25 | } 26 | 27 | -(void)flowingMenuNeedsDismissMenu 28 | { 29 | [self dismissViewControllerAnimated:YES completion:nil]; 30 | } 31 | 32 | #pragma mark - Table view data source 33 | 34 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 35 | 36 | return 1; 37 | } 38 | 39 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 40 | 41 | return 20; 42 | } 43 | 44 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 45 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" ]; 46 | if (!cell) { 47 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"reuseIdentifier"]; 48 | } 49 | cell.textLabel.text = [NSString stringWithFormat:@"this is %li row",indexPath.row]; 50 | return cell; 51 | } 52 | 53 | -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 54 | { 55 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 56 | NSLog(@"click at indexPath :%@",indexPath); 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Source-oc/FlowingMenuTransitionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionManager.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FlowingMenuTransitionStatus.h" 11 | #import "ToViewControllerNeedsConform.h" 12 | #import "FromViewControllerNeedsConform.h" 13 | 14 | /// Defines the animation mode of the transition. 15 | typedef NS_ENUM(NSInteger, AnimationMode){ 16 | AnimationModePresentation, 17 | AnimationModeDismissal 18 | }; 19 | /** 20 | The `FlowingMenuTransitionManager` is a concrete subclass of 21 | `UIPercentDrivenInteractiveTransition` which aims to drive the transition between 22 | two views by providing an flowing/elastic and bouncing animation effect. 23 | 24 | You must adopt the `FlowingMenuDelegate` if you want to make the transition 25 | interactive. 26 | */ 27 | @interface FlowingMenuTransitionManager : UIPercentDrivenInteractiveTransition 28 | 29 | /** 30 | The delegate for the flowing transition manager. 31 | 32 | The delegate must adopt the `FlowingMenuDelegate` protocol and implement the 33 | required methods to manage the interactive animations. 34 | */ 35 | @property(weak, nonatomic) idfromVCDelegate; 36 | @property(weak, nonatomic) idtoVCDelegate; 37 | @property(nonatomic) AnimationMode animationMode; 38 | 39 | +(instancetype)manager; 40 | 41 | -(void)setInteractivePresentationView:(UIView *)view; 42 | 43 | -(void)view:(UIView *)otherView presentMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion; 44 | 45 | -(void)view:(UIView *)otherView dismissMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Source-oc/FlowingMenuTransitionManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionManager.m 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import "FlowingMenuTransitionManager.h" 10 | 11 | @interface FlowingMenuTransitionManager () 12 | @property(strong, nonatomic) CAShapeLayer *shapeLayer; 13 | @property(strong, nonatomic) CAShapeLayer *shapeMaskLayer; 14 | @property(strong, nonatomic) CADisplayLink *displayLink; 15 | @property(nonatomic) BOOL interactive; 16 | 17 | @property(strong, nonatomic) NSArray<__kindof UIView *>*controlViews; 18 | 19 | @property(strong, nonatomic) UIView *bottomView; 20 | @end 21 | @implementation FlowingMenuTransitionManager 22 | 23 | + (instancetype)manager 24 | { 25 | static FlowingMenuTransitionManager *_manager = nil; 26 | static dispatch_once_t onceToken; 27 | dispatch_once(&onceToken, ^{ 28 | _manager = [[self alloc] init]; 29 | }); 30 | return _manager; 31 | } 32 | 33 | -(instancetype)init 34 | { 35 | self = [super init]; 36 | if (self) { 37 | self.animationMode = AnimationModePresentation; 38 | self.interactive = NO; 39 | self.displayLink.paused = YES; 40 | NSMutableArray *arr = [NSMutableArray array]; 41 | for (int i=0; i<8; i++) { 42 | UIView *view = [UIView new]; 43 | [arr addObject:view]; 44 | } 45 | self.controlViews = arr; 46 | self.shapeLayer = [CAShapeLayer layer]; 47 | self.shapeMaskLayer = [CAShapeLayer layer]; 48 | } 49 | return self; 50 | } 51 | 52 | -(CADisplayLink *)displayLink 53 | { 54 | if (!_displayLink) { 55 | _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateShapeLayer)]; 56 | _displayLink.paused = YES; 57 | [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; 58 | } 59 | return _displayLink; 60 | } 61 | 62 | - (void)view:(UIView *)otherView presentMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion 63 | { 64 | UIView *ov = [otherView snapshotViewAfterScreenUpdates:YES]; 65 | if (!ov) { 66 | return; 67 | } 68 | ov.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 69 | 70 | [containerView addSubview:ov]; 71 | 72 | // Add the tap gesture 73 | [self addTapGestureToView:ov]; 74 | 75 | 76 | // Add a mask to the menu to create the bubble effect 77 | CAShapeLayer *maskLayer = [CAShapeLayer layer]; 78 | menuView.layer.mask = maskLayer; 79 | 80 | CGFloat menuWidth = 0.0; 81 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(widthOfMenuView:)]) { 82 | menuWidth = [self.fromVCDelegate widthOfMenuView:menuView]; 83 | }else{ 84 | menuWidth = [self widthOfMenuView:menuView]; 85 | } 86 | 87 | //use bottomView to avoid gesture conflict when menview is kindof UIScrollerView 88 | if ([menuView isKindOfClass:[UIScrollView class]]) { 89 | self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, menuWidth, menuView.bounds.size.height)]; 90 | [self.bottomView addSubview:menuView]; 91 | [containerView addSubview:self.bottomView]; 92 | [self setInteractiveDismissView:self.bottomView]; 93 | }else{ 94 | [containerView addSubview:menuView]; 95 | [self setInteractiveDismissView:menuView]; 96 | } 97 | 98 | 99 | CGFloat maxSideSize = MAX(menuView.bounds.size.width, menuView.bounds.size.height); 100 | 101 | CGRect beginRect = CGRectMake(1, menuView.bounds.size.height / 2 - 1, 2, 2); 102 | CGRect middleRect = CGRectMake(-menuWidth, 0, menuWidth * 2, menuView.bounds.size.height); 103 | 104 | CGRect endRect = CGRectMake(-maxSideSize, menuView.bounds.size.height / 2 - maxSideSize, maxSideSize * 2, maxSideSize * 2); 105 | 106 | 107 | UIBezierPath *beginPath = [UIBezierPath bezierPathWithRect:menuView.bounds]; 108 | [beginPath appendPath:[[UIBezierPath bezierPathWithOvalInRect:beginRect] bezierPathByReversingPath]]; 109 | 110 | UIBezierPath *middlePath = [UIBezierPath bezierPathWithRect:menuView.bounds]; 111 | [middlePath appendPath:[[UIBezierPath bezierPathWithOvalInRect:middleRect] bezierPathByReversingPath]]; 112 | 113 | UIBezierPath *endPath = [UIBezierPath bezierPathWithRect:menuView.bounds]; 114 | [endPath appendPath:[[UIBezierPath bezierPathWithOvalInRect:endRect] bezierPathByReversingPath]]; 115 | 116 | 117 | 118 | // Defining the menu frame 119 | CGRect menuFrame = menuView.frame; 120 | menuFrame.size.width = menuWidth; 121 | menuView.frame = menuFrame; 122 | 123 | // Start the animations 124 | if(!self.interactive) { 125 | CAKeyframeAnimation *bubbleAnim = [CAKeyframeAnimation animationWithKeyPath:@"path"]; 126 | bubbleAnim.values = @[(__bridge id )[UIBezierPath bezierPathWithOvalInRect:beginRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:middleRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:endRect].CGPath]; 127 | bubbleAnim.keyTimes = @[@0, @0.4, @1]; 128 | bubbleAnim.duration = duration; 129 | bubbleAnim.removedOnCompletion = NO; 130 | bubbleAnim.fillMode = kCAFillModeForwards; 131 | [maskLayer addAnimation:bubbleAnim forKey:@"bubbleAnim"]; 132 | 133 | }else { 134 | // Last control points help us to know the menu height 135 | self.controlViews[7].center = CGPointMake(0, menuView.bounds.size.height); 136 | 137 | // Be sure there is no animation running 138 | [self.shapeMaskLayer removeAllAnimations]; 139 | 140 | // Retrieve the shape color 141 | UIColor *shapeColor = nil; 142 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(colorOfElasticShapeInFlowingMenu:)]) { 143 | shapeColor = [self.fromVCDelegate colorOfElasticShapeInFlowingMenu:menuView]; 144 | }else{ 145 | shapeColor = [self colorOfElasticShapeInFlowingMenu:menuView]; 146 | } 147 | 148 | if (!shapeColor) { 149 | shapeColor = menuView.backgroundColor ?: [UIColor blackColor]; 150 | } 151 | 152 | self.shapeMaskLayer.path = [UIBezierPath bezierPathWithRect:ov.bounds].CGPath; 153 | self.shapeLayer.actions = @{@"position" : [NSNull null], @"bounds" : [NSNull null], @"path" : [NSNull null]}; 154 | self.shapeLayer.backgroundColor = shapeColor.CGColor; 155 | self.shapeLayer.fillColor = shapeColor.CGColor; 156 | 157 | // Add the mask to create the bubble effect 158 | self.shapeLayer.mask = self.shapeMaskLayer; 159 | 160 | 161 | // Add the shape layer to container view 162 | [containerView.layer addSublayer:self.shapeLayer]; 163 | 164 | for (UIView *v in self.controlViews) { 165 | [v removeFromSuperview]; 166 | [containerView addSubview:v]; 167 | } 168 | 169 | } 170 | 171 | containerView.userInteractionEnabled = NO; 172 | 173 | [UIView animateWithDuration:duration animations:^{ 174 | menuView.frame = CGRectMake(0, menuFrame.origin.y, menuFrame.size.width, menuFrame.size.height); 175 | otherView.alpha = 0; 176 | ov.alpha = 0.4; 177 | 178 | } completion:^(BOOL finished) { 179 | 180 | if (self.interactive && ![status transitionWasCancelled]) { 181 | self.interactive = NO; 182 | 183 | CAKeyframeAnimation *bubbleAnim = [CAKeyframeAnimation animationWithKeyPath:@"path"]; 184 | bubbleAnim.values = @[(__bridge id )[UIBezierPath bezierPathWithOvalInRect:beginRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:middleRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:endRect].CGPath]; 185 | bubbleAnim.keyTimes = @[@0, @0.4, @1]; 186 | bubbleAnim.duration = duration; 187 | bubbleAnim.removedOnCompletion = NO; 188 | bubbleAnim.fillMode = kCAFillModeForwards; 189 | [maskLayer addAnimation:bubbleAnim forKey:@"bubbleAnim"]; 190 | 191 | 192 | CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"path"]; 193 | anim.values = @[(__bridge id )beginPath.CGPath,(__bridge id )middlePath.CGPath,(__bridge id )endPath.CGPath]; 194 | anim.keyTimes = @[@0, @0.4, @1]; 195 | anim.duration = duration; 196 | anim.removedOnCompletion = NO; 197 | anim.fillMode = kCAFillModeForwards; 198 | [self.shapeMaskLayer addAnimation:anim forKey:@"bubbleAnim"]; 199 | 200 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:0.43 initialSpringVelocity:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 201 | for (UIView *v in self.controlViews) { 202 | v.center = CGPointMake(menuWidth, v.center.y); 203 | } 204 | 205 | } completion:^(BOOL finished) { 206 | 207 | [self.shapeLayer removeFromSuperlayer]; 208 | containerView.userInteractionEnabled = YES; 209 | 210 | menuView.layer.mask = nil; 211 | self.displayLink.paused = YES; 212 | completion(); 213 | 214 | }]; 215 | }else { 216 | menuView.layer.mask = nil; 217 | self.displayLink.paused = YES; 218 | 219 | containerView.userInteractionEnabled = YES; 220 | completion(); 221 | } 222 | }]; 223 | } 224 | 225 | - (void)view:(UIView *)otherView dismissMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion 226 | { 227 | otherView.frame = containerView.bounds; 228 | UIView *ov = [otherView snapshotViewAfterScreenUpdates:YES]; 229 | CGRect menuFrame = menuView.frame; 230 | 231 | [containerView addSubview:otherView]; 232 | [containerView addSubview:ov]; 233 | [containerView addSubview:menuView]; 234 | 235 | otherView.alpha = 0; 236 | ov.alpha = 0.4; 237 | 238 | 239 | [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 240 | menuView.frame = CGRectMake(-menuFrame.size.width, menuFrame.origin.y, menuFrame.size.width, menuFrame.size.height); 241 | otherView.alpha = 1; 242 | ov.alpha = 1; 243 | } completion:^(BOOL finished) { 244 | 245 | BOOL canceled = [status.context transitionWasCancelled]; 246 | 247 | if (!canceled) { 248 | [self.bottomView removeFromSuperview]; 249 | }else{ 250 | 251 | if ([menuView isKindOfClass:[UIScrollView class]]) { 252 | [menuView removeFromSuperview]; 253 | [self addTapGestureToView:ov]; 254 | [self.bottomView addSubview:menuView]; 255 | [containerView insertSubview:self.bottomView aboveSubview:ov]; 256 | }else{ 257 | [self addTapGestureToView:ov]; 258 | } 259 | } 260 | 261 | completion(); 262 | }]; 263 | } 264 | 265 | #pragma mark - private 266 | 267 | - (void)updateShapeLayer { 268 | self.shapeLayer.path = [self currentPath]; 269 | } 270 | 271 | - (CGPathRef)currentPath{ 272 | UIBezierPath *bezierPath = [UIBezierPath new]; 273 | 274 | [bezierPath moveToPoint:CGPointZero]; 275 | [bezierPath addLineToPoint:CGPointMake(self.controlViews[0].center.x, 0)]; 276 | [bezierPath addCurveToPoint:self.controlViews[2].center controlPoint1:self.controlViews[0].center controlPoint2:self.controlViews[1].center]; 277 | [bezierPath addCurveToPoint:self.controlViews[4].center controlPoint1:self.controlViews[3].center controlPoint2:self.controlViews[4].center]; 278 | [bezierPath addCurveToPoint:self.controlViews[6].center controlPoint1:self.controlViews[4].center controlPoint2:self.controlViews[5].center]; 279 | [bezierPath addLineToPoint:CGPointMake(0, self.controlViews[7].center.y)]; 280 | [bezierPath closePath]; 281 | 282 | return bezierPath.CGPath; 283 | } 284 | 285 | - (void)moveControlPointsToPoint:(CGPoint )position waveWidth:(CGFloat)waveWidth 286 | { 287 | CGFloat height = self.controlViews[7].center.y; 288 | 289 | CGFloat minTopY = MIN((position.y - height / 2) * 0.28, 0); 290 | CGFloat maxBottomY = MAX(height + (position.y - height / 2) * 0.28, height); 291 | 292 | CGFloat leftPartWidth = position.y - minTopY; 293 | CGFloat rightPartWidth = maxBottomY - position.y; 294 | 295 | self.controlViews[0].center = CGPointMake(position.x, minTopY); 296 | self.controlViews[1].center = CGPointMake(position.x, minTopY + leftPartWidth * 0.44); 297 | self.controlViews[2].center = CGPointMake(position.x + waveWidth * 0.64, minTopY + leftPartWidth * 0.71); 298 | self.controlViews[3].center = CGPointMake(position.x + waveWidth * 1.36, position.y); 299 | self.controlViews[4].center = CGPointMake(position.x + waveWidth * 0.64, maxBottomY - rightPartWidth * 0.71); 300 | self.controlViews[5].center = CGPointMake(position.x, maxBottomY - (rightPartWidth * 0.44)); 301 | self.controlViews[6].center = CGPointMake(position.x, height); 302 | 303 | } 304 | 305 | #pragma mark - FlowingMenuTransitionManager + UIGestureRecognizer 306 | 307 | - (void)addTapGestureToView:(UIView*)view { 308 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToDismissAction:)]; 309 | tapGesture.numberOfTapsRequired = 1; 310 | [view addGestureRecognizer:tapGesture]; 311 | } 312 | 313 | -(void)setInteractiveDismissView:(UIView *)view { 314 | UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panToDismissAction:)]; 315 | panGesture.maximumNumberOfTouches = 1; 316 | [view addGestureRecognizer:panGesture]; 317 | } 318 | 319 | -(void)setInteractivePresentationView:(UIView *)view{ 320 | UIScreenEdgePanGestureRecognizer *screenEdgePanGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(panToPresentAction:)]; 321 | screenEdgePanGesture.edges = UIRectEdgeLeft; 322 | [view addGestureRecognizer:screenEdgePanGesture]; 323 | } 324 | 325 | -(void)tapToDismissAction:(UITapGestureRecognizer *)tapGesture { 326 | if (self.toVCDelegate && [self.toVCDelegate respondsToSelector:@selector(flowingMenuNeedsDismissMenu)]) { 327 | [self.toVCDelegate flowingMenuNeedsDismissMenu]; 328 | } 329 | } 330 | 331 | -(void)panToDismissAction:(UIPanGestureRecognizer *)panGesture { 332 | UIView *view = panGesture.view; 333 | 334 | CGFloat menuWidth = 0.0; 335 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(widthOfMenuView:)]) { 336 | menuWidth = [self.fromVCDelegate widthOfMenuView:view]; 337 | }else{ 338 | menuWidth = [self widthOfMenuView:view]; 339 | } 340 | CGPoint translation = [panGesture translationInView:view]; 341 | 342 | CGFloat percentage = MIN(MAX(translation.x / menuWidth * -1, 0), 1); 343 | 344 | if (panGesture.state == UIGestureRecognizerStateBegan) { 345 | self.interactive = YES; 346 | // Asking the delegate the dismiss the menu 347 | if (self.toVCDelegate && [self.toVCDelegate respondsToSelector:@selector(flowingMenuNeedsDismissMenu)]) { 348 | [self.toVCDelegate flowingMenuNeedsDismissMenu]; 349 | } 350 | }else if (panGesture.state == UIGestureRecognizerStateChanged){ 351 | [self updateInteractiveTransition:percentage]; 352 | }else if(panGesture.state == UIGestureRecognizerStateCancelled || panGesture.state == UIGestureRecognizerStateEnded) { 353 | self.interactive = NO; 354 | if (percentage > 0.2) { 355 | [self finishInteractiveTransition]; 356 | }else{ 357 | [self cancelInteractiveTransition]; 358 | } 359 | } 360 | } 361 | 362 | -(void)panToPresentAction:(UIScreenEdgePanGestureRecognizer *)panGesture { 363 | UIView *view = panGesture.view; 364 | CGPoint translation = [panGesture translationInView:view]; 365 | CGFloat yLocation = [panGesture locationInView:view].y; 366 | 367 | CGFloat menuWidth = 0.0; 368 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(widthOfMenuView:)]) { 369 | menuWidth = [self.fromVCDelegate widthOfMenuView:view]; 370 | }else{ 371 | menuWidth = [self widthOfMenuView:view]; 372 | } 373 | 374 | CGFloat percentage = MIN(MAX(translation.x / (menuWidth/2), 0), 1); 375 | 376 | if (panGesture.state == UIGestureRecognizerStateBegan) { 377 | self.interactive = YES; 378 | // Asking the delegate the present the menu 379 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(flowingMenuNeedsPresentMenu)]) { 380 | [self.fromVCDelegate flowingMenuNeedsPresentMenu]; 381 | } 382 | }else if (panGesture.state == UIGestureRecognizerStateChanged){ 383 | [self updateInteractiveTransition:percentage]; 384 | 385 | CGFloat waveWidth = translation.x * 0.9; 386 | CGFloat left = waveWidth * 0.1; 387 | 388 | // Update the control points 389 | [self moveControlPointsToPoint:CGPointMake(left, yLocation) waveWidth:waveWidth]; 390 | [self updateShapeLayer]; 391 | }else /*if(panGesture.state == UIGestureRecognizerStateCancelled || panGesture.state == UIGestureRecognizerStateEnded)*/{ 392 | self.displayLink.paused = NO; 393 | if( percentage < 1 ){ 394 | self.interactive = NO; 395 | [self moveControlPointsToPoint:CGPointMake(0, yLocation) waveWidth:0]; 396 | [self cancelInteractiveTransition]; 397 | } 398 | else { 399 | [self finishInteractiveTransition]; 400 | } 401 | 402 | } 403 | } 404 | 405 | 406 | #pragma mark - FlowingMenuDelegate 407 | 408 | - (CGFloat)widthOfMenuView:(UIView *)menuView 409 | { 410 | return menuView.bounds.size.width * 2 / 3; 411 | } 412 | 413 | -(UIColor *)colorOfElasticShapeInFlowingMenu:(UIView *)menuView 414 | { 415 | return [UIColor cyanColor]; 416 | } 417 | 418 | #pragma mark - UIViewControllerTransitioningDelegate 419 | 420 | -(id)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source 421 | { 422 | self.animationMode = AnimationModePresentation; 423 | return self; 424 | } 425 | 426 | -(id)animationControllerForDismissedController:(UIViewController *)dismissed 427 | { 428 | self.animationMode = AnimationModeDismissal; 429 | return self; 430 | } 431 | 432 | - (nullable id )interactionControllerForPresentation:(id )animator 433 | { 434 | self.animationMode = AnimationModePresentation; 435 | return self.interactive ? self : nil; 436 | } 437 | 438 | -(id)interactionControllerForDismissal:(id)animator 439 | { 440 | self.animationMode = AnimationModeDismissal; 441 | return self.interactive ? self : nil; 442 | } 443 | 444 | #pragma mark - UIViewControllerAnimatedTransitioning 445 | 446 | - (void)animateTransition:(id)transitionContext 447 | { 448 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 449 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 450 | 451 | UIView *containerView = transitionContext.containerView; 452 | UIView *menuView = (self.animationMode == AnimationModePresentation) ? toVC.view : fromVC.view; 453 | UIView *otherView = (self.animationMode == AnimationModePresentation) ? fromVC.view : toVC.view; ; 454 | 455 | FlowingMenuTransitionStatus *status = [[FlowingMenuTransitionStatus alloc] initWithContext:transitionContext]; 456 | 457 | if (self.animationMode == AnimationModePresentation) { 458 | [self view:otherView presentMenuView:menuView containerView:containerView status:status duration:[self transitionDuration:transitionContext] completion:^{ 459 | BOOL canceled = [transitionContext transitionWasCancelled]; 460 | [transitionContext completeTransition:!canceled]; 461 | 462 | if (!canceled) { 463 | [[UIApplication sharedApplication].keyWindow insertSubview:fromVC.view atIndex:0]; 464 | } 465 | }]; 466 | }else{ 467 | [self view:otherView dismissMenuView:menuView containerView:containerView status:status duration:[self transitionDuration:transitionContext] completion:^{ 468 | BOOL canceled = [transitionContext transitionWasCancelled]; 469 | [transitionContext completeTransition:!canceled]; 470 | 471 | if (!canceled) { 472 | [[UIApplication sharedApplication].keyWindow insertSubview:fromVC.view atIndex:0]; 473 | } 474 | }]; 475 | } 476 | } 477 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext 478 | { 479 | return self.interactive ? 0.6 : 0.25; 480 | } 481 | 482 | @end 483 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Source-oc/FlowingMenuTransitionStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionStatus.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | The FlowingMenuTransitionStatus object aims to make the transition manager 12 | testable by providing a concevient way to access the 13 | `UIViewControllerContextTransitioning` `transitionWasCancelled` method. 14 | */ 15 | @interface FlowingMenuTransitionStatus : NSObject 16 | 17 | @property (readonly,nonatomic) id context; 18 | /// Initializer for testing purpose. 19 | -(instancetype)initWithCancelledOrNot:(BOOL)cancelled; 20 | 21 | /// Initializer for running purpose. 22 | - (instancetype)initWithContext:(id)context; 23 | 24 | /** 25 | Returns a Boolean value indicating whether the transition was canceled. 26 | 27 | true if the transition was canceled or false if it is ongoing or finished 28 | normally. 29 | 30 | - returns: true if the transition was canceled or NO if it is ongoing or 31 | finished normally. 32 | */ 33 | - (BOOL)transitionWasCancelled; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Source-oc/FlowingMenuTransitionStatus.m: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionStatus.m 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import "FlowingMenuTransitionStatus.h" 10 | 11 | @interface FlowingMenuTransitionStatus () 12 | @property (readonly,nonatomic) BOOL cancelled; 13 | @end 14 | @implementation FlowingMenuTransitionStatus 15 | 16 | - (instancetype)initWithCancelledOrNot:(BOOL)cancelled 17 | { 18 | self = [super init]; 19 | if (self) { 20 | self->_context = nil; 21 | self->_cancelled = cancelled; 22 | } 23 | return self; 24 | } 25 | 26 | - (instancetype)initWithContext:(id)context 27 | { 28 | self = [super init]; 29 | if (self) { 30 | self->_context = context; 31 | self->_cancelled = NO; 32 | } 33 | return self; 34 | } 35 | 36 | - (BOOL)transitionWasCancelled 37 | { 38 | return self.context ? [self.context transitionWasCancelled] : self.cancelled; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Source-oc/FromViewControllerNeedsConform.h: -------------------------------------------------------------------------------- 1 | // 2 | // FromViewControllerNeedsConform.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol FromViewControllerNeedsConform 12 | 13 | @optional 14 | /** 15 | Called by the flowing menu transition manager when it needs to display the 16 | menu. 17 | 18 | - parameter menuView: The menu view which will be displayed. 19 | - returns: The width of the menu view. Outside the menu view a black overlay 20 | will be displayed. 21 | */ 22 | -(CGFloat)widthOfMenuView:(UIView *)menuView; 23 | 24 | 25 | /** 26 | Asks the delegate the color of the shape drawn during an interactive 27 | transition. 28 | 29 | - returns: The shape color. If nil it will use the menu background color and 30 | if menu has no background color, the shape will be black. 31 | */ 32 | -(UIColor *)colorOfElasticShapeInFlowingMenu:(UIView *)menuView; 33 | 34 | /** 35 | Called by the flowing menu transition manager when the interactive transition 36 | begins its presentation. You should implement this methods to present your 37 | menu view. 38 | 39 | - parameter flowingMenu: The flowing menu transition manager which needs 40 | present the menu. 41 | */ 42 | - (void)flowingMenuNeedsPresentMenu; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/Source-oc/ToViewControllerNeedsConform.h: -------------------------------------------------------------------------------- 1 | // 2 | // ToViewControllerNeedsConform.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol ToViewControllerNeedsConform 12 | /** 13 | Called by the flowing menu transition manager when the interactive transition 14 | begins its dismissal. You should implement this methods to dismiss your menu 15 | view. 16 | 17 | - parameter flowingMenu: The flowing menu transition manager which needs 18 | dismiss the menu. 19 | */ 20 | -(void)flowingMenuNeedsDismissMenu; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /Example/FlowingMenuExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FlowingMenuExample 4 | // 5 | // Created by cheaterhu on 2017/4/13. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Example/FlowingMenuExampleTests/FlowingMenuExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuExampleTests.m 3 | // FlowingMenuExampleTests 4 | // 5 | // Created by cheaterhu on 2017/4/13. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FlowingMenuExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FlowingMenuExampleTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /Example/FlowingMenuExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/FlowingMenuExampleUITests/FlowingMenuExampleUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuExampleUITests.m 3 | // FlowingMenuExampleUITests 4 | // 5 | // Created by cheaterhu on 2017/4/13. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FlowingMenuExampleUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation FlowingMenuExampleUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/FlowingMenuExampleUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-present Yannick Loriot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YLFlowingMenu 2 | 3 | YLFlowingMenu provides an interactive transition manager to display menu with a flowing and bouncing effects. 4 | 5 |

6 | YLFlowingMenu 7 |

8 | 9 | Checkout the Swift counterpart project here: https://github.com/yannickl/FlowingMenu. 10 | 11 | ## Contact 12 | 13 | Yannick Loriot 14 | - [https://twitter.com/yannickloriot](https://twitter.com/yannickloriot) 15 | - [contact@yannickloriot.com](mailto:contact@yannickloriot.com) 16 | 17 | ## License (MIT) 18 | 19 | Copyright (c) 2015-present - Yannick Loriot 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in 29 | all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 37 | THE SOFTWARE. 38 | -------------------------------------------------------------------------------- /Source/FlowingMenuTransitionManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionManager.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "FlowingMenuTransitionStatus.h" 11 | #import "ToViewControllerNeedsConform.h" 12 | #import "FromViewControllerNeedsConform.h" 13 | 14 | /// Defines the animation mode of the transition. 15 | typedef NS_ENUM(NSInteger, AnimationMode){ 16 | AnimationModePresentation, 17 | AnimationModeDismissal 18 | }; 19 | /** 20 | The `FlowingMenuTransitionManager` is a concrete subclass of 21 | `UIPercentDrivenInteractiveTransition` which aims to drive the transition between 22 | two views by providing an flowing/elastic and bouncing animation effect. 23 | 24 | You must adopt the `FlowingMenuDelegate` if you want to make the transition 25 | interactive. 26 | */ 27 | @interface FlowingMenuTransitionManager : UIPercentDrivenInteractiveTransition 28 | 29 | /** 30 | The delegate for the flowing transition manager. 31 | 32 | The delegate must adopt the `FlowingMenuDelegate` protocol and implement the 33 | required methods to manage the interactive animations. 34 | */ 35 | @property(weak, nonatomic) idfromVCDelegate; 36 | @property(weak, nonatomic) idtoVCDelegate; 37 | @property(nonatomic) AnimationMode animationMode; 38 | 39 | +(instancetype)manager; 40 | 41 | -(void)setInteractivePresentationView:(UIView *)view; 42 | 43 | -(void)view:(UIView *)otherView presentMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion; 44 | 45 | -(void)view:(UIView *)otherView dismissMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Source/FlowingMenuTransitionManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionManager.m 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import "FlowingMenuTransitionManager.h" 10 | 11 | @interface FlowingMenuTransitionManager () 12 | @property(strong, nonatomic) CAShapeLayer *shapeLayer; 13 | @property(strong, nonatomic) CAShapeLayer *shapeMaskLayer; 14 | @property(strong, nonatomic) CADisplayLink *displayLink; 15 | @property(nonatomic) BOOL interactive; 16 | 17 | @property(strong, nonatomic) NSArray<__kindof UIView *>*controlViews; 18 | 19 | @property(strong, nonatomic) UIView *bottomView; 20 | @end 21 | @implementation FlowingMenuTransitionManager 22 | 23 | + (instancetype)manager 24 | { 25 | static FlowingMenuTransitionManager *_manager = nil; 26 | static dispatch_once_t onceToken; 27 | dispatch_once(&onceToken, ^{ 28 | _manager = [[self alloc] init]; 29 | }); 30 | return _manager; 31 | } 32 | 33 | -(instancetype)init 34 | { 35 | self = [super init]; 36 | if (self) { 37 | self.animationMode = AnimationModePresentation; 38 | self.interactive = NO; 39 | self.displayLink.paused = YES; 40 | NSMutableArray *arr = [NSMutableArray array]; 41 | for (int i=0; i<8; i++) { 42 | UIView *view = [UIView new]; 43 | [arr addObject:view]; 44 | } 45 | self.controlViews = arr; 46 | self.shapeLayer = [CAShapeLayer layer]; 47 | self.shapeMaskLayer = [CAShapeLayer layer]; 48 | } 49 | return self; 50 | } 51 | 52 | -(CADisplayLink *)displayLink 53 | { 54 | if (!_displayLink) { 55 | _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateShapeLayer)]; 56 | _displayLink.paused = YES; 57 | [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; 58 | } 59 | return _displayLink; 60 | } 61 | 62 | - (void)view:(UIView *)otherView presentMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion 63 | { 64 | UIView *ov = [otherView snapshotViewAfterScreenUpdates:YES]; 65 | if (!ov) { 66 | return; 67 | } 68 | ov.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 69 | 70 | [containerView addSubview:ov]; 71 | 72 | // Add the tap gesture 73 | [self addTapGestureToView:ov]; 74 | 75 | 76 | // Add a mask to the menu to create the bubble effect 77 | CAShapeLayer *maskLayer = [CAShapeLayer layer]; 78 | menuView.layer.mask = maskLayer; 79 | 80 | CGFloat menuWidth = 0.0; 81 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(widthOfMenuView:)]) { 82 | menuWidth = [self.fromVCDelegate widthOfMenuView:menuView]; 83 | }else{ 84 | menuWidth = [self widthOfMenuView:menuView]; 85 | } 86 | 87 | //use bottomView to avoid gesture conflict when menview is kindof UIScrollerView 88 | if ([menuView isKindOfClass:[UIScrollView class]]) { 89 | self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, menuWidth, menuView.bounds.size.height)]; 90 | [self.bottomView addSubview:menuView]; 91 | [containerView addSubview:self.bottomView]; 92 | [self setInteractiveDismissView:self.bottomView]; 93 | }else{ 94 | [containerView addSubview:menuView]; 95 | [self setInteractiveDismissView:menuView]; 96 | } 97 | 98 | 99 | CGFloat maxSideSize = MAX(menuView.bounds.size.width, menuView.bounds.size.height); 100 | 101 | CGRect beginRect = CGRectMake(1, menuView.bounds.size.height / 2 - 1, 2, 2); 102 | CGRect middleRect = CGRectMake(-menuWidth, 0, menuWidth * 2, menuView.bounds.size.height); 103 | 104 | CGRect endRect = CGRectMake(-maxSideSize, menuView.bounds.size.height / 2 - maxSideSize, maxSideSize * 2, maxSideSize * 2); 105 | 106 | 107 | UIBezierPath *beginPath = [UIBezierPath bezierPathWithRect:menuView.bounds]; 108 | [beginPath appendPath:[[UIBezierPath bezierPathWithOvalInRect:beginRect] bezierPathByReversingPath]]; 109 | 110 | UIBezierPath *middlePath = [UIBezierPath bezierPathWithRect:menuView.bounds]; 111 | [middlePath appendPath:[[UIBezierPath bezierPathWithOvalInRect:middleRect] bezierPathByReversingPath]]; 112 | 113 | UIBezierPath *endPath = [UIBezierPath bezierPathWithRect:menuView.bounds]; 114 | [endPath appendPath:[[UIBezierPath bezierPathWithOvalInRect:endRect] bezierPathByReversingPath]]; 115 | 116 | 117 | 118 | // Defining the menu frame 119 | CGRect menuFrame = menuView.frame; 120 | menuFrame.size.width = menuWidth; 121 | menuView.frame = menuFrame; 122 | 123 | // Start the animations 124 | if(!self.interactive) { 125 | CAKeyframeAnimation *bubbleAnim = [CAKeyframeAnimation animationWithKeyPath:@"path"]; 126 | bubbleAnim.values = @[(__bridge id )[UIBezierPath bezierPathWithOvalInRect:beginRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:middleRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:endRect].CGPath]; 127 | bubbleAnim.keyTimes = @[@0, @0.4, @1]; 128 | bubbleAnim.duration = duration; 129 | bubbleAnim.removedOnCompletion = NO; 130 | bubbleAnim.fillMode = kCAFillModeForwards; 131 | [maskLayer addAnimation:bubbleAnim forKey:@"bubbleAnim"]; 132 | 133 | }else { 134 | // Last control points help us to know the menu height 135 | self.controlViews[7].center = CGPointMake(0, menuView.bounds.size.height); 136 | 137 | // Be sure there is no animation running 138 | [self.shapeMaskLayer removeAllAnimations]; 139 | 140 | // Retrieve the shape color 141 | UIColor *shapeColor = nil; 142 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(colorOfElasticShapeInFlowingMenu:)]) { 143 | shapeColor = [self.fromVCDelegate colorOfElasticShapeInFlowingMenu:menuView]; 144 | }else{ 145 | shapeColor = [self colorOfElasticShapeInFlowingMenu:menuView]; 146 | } 147 | 148 | if (!shapeColor) { 149 | shapeColor = menuView.backgroundColor ?: [UIColor blackColor]; 150 | } 151 | 152 | self.shapeMaskLayer.path = [UIBezierPath bezierPathWithRect:ov.bounds].CGPath; 153 | self.shapeLayer.actions = @{@"position" : [NSNull null], @"bounds" : [NSNull null], @"path" : [NSNull null]}; 154 | self.shapeLayer.backgroundColor = shapeColor.CGColor; 155 | self.shapeLayer.fillColor = shapeColor.CGColor; 156 | 157 | // Add the mask to create the bubble effect 158 | self.shapeLayer.mask = self.shapeMaskLayer; 159 | 160 | 161 | // Add the shape layer to container view 162 | [containerView.layer addSublayer:self.shapeLayer]; 163 | 164 | for (UIView *v in self.controlViews) { 165 | [v removeFromSuperview]; 166 | [containerView addSubview:v]; 167 | } 168 | 169 | } 170 | 171 | containerView.userInteractionEnabled = NO; 172 | 173 | [UIView animateWithDuration:duration animations:^{ 174 | menuView.frame = CGRectMake(0, menuFrame.origin.y, menuFrame.size.width, menuFrame.size.height); 175 | otherView.alpha = 0; 176 | ov.alpha = 0.4; 177 | 178 | } completion:^(BOOL finished) { 179 | 180 | if (self.interactive && ![status transitionWasCancelled]) { 181 | self.interactive = NO; 182 | 183 | CAKeyframeAnimation *bubbleAnim = [CAKeyframeAnimation animationWithKeyPath:@"path"]; 184 | bubbleAnim.values = @[(__bridge id )[UIBezierPath bezierPathWithOvalInRect:beginRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:middleRect].CGPath,(__bridge id )[UIBezierPath bezierPathWithOvalInRect:endRect].CGPath]; 185 | bubbleAnim.keyTimes = @[@0, @0.4, @1]; 186 | bubbleAnim.duration = duration; 187 | bubbleAnim.removedOnCompletion = NO; 188 | bubbleAnim.fillMode = kCAFillModeForwards; 189 | [maskLayer addAnimation:bubbleAnim forKey:@"bubbleAnim"]; 190 | 191 | 192 | CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"path"]; 193 | anim.values = @[(__bridge id )beginPath.CGPath,(__bridge id )middlePath.CGPath,(__bridge id )endPath.CGPath]; 194 | anim.keyTimes = @[@0, @0.4, @1]; 195 | anim.duration = duration; 196 | anim.removedOnCompletion = NO; 197 | anim.fillMode = kCAFillModeForwards; 198 | [self.shapeMaskLayer addAnimation:anim forKey:@"bubbleAnim"]; 199 | 200 | [UIView animateWithDuration:duration delay:0 usingSpringWithDamping:0.43 initialSpringVelocity:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 201 | for (UIView *v in self.controlViews) { 202 | v.center = CGPointMake(menuWidth, v.center.y); 203 | } 204 | 205 | } completion:^(BOOL finished) { 206 | 207 | [self.shapeLayer removeFromSuperlayer]; 208 | containerView.userInteractionEnabled = YES; 209 | 210 | menuView.layer.mask = nil; 211 | self.displayLink.paused = YES; 212 | completion(); 213 | 214 | }]; 215 | }else { 216 | menuView.layer.mask = nil; 217 | self.displayLink.paused = YES; 218 | 219 | containerView.userInteractionEnabled = YES; 220 | completion(); 221 | } 222 | }]; 223 | } 224 | 225 | - (void)view:(UIView *)otherView dismissMenuView:(UIView *)menuView containerView:(UIView *)containerView status:(FlowingMenuTransitionStatus *)status duration:(NSTimeInterval)duration completion:(void (^)())completion 226 | { 227 | otherView.frame = containerView.bounds; 228 | UIView *ov = [otherView snapshotViewAfterScreenUpdates:YES]; 229 | CGRect menuFrame = menuView.frame; 230 | 231 | [containerView addSubview:otherView]; 232 | [containerView addSubview:ov]; 233 | [containerView addSubview:menuView]; 234 | 235 | otherView.alpha = 0; 236 | ov.alpha = 0.4; 237 | 238 | 239 | [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ 240 | menuView.frame = CGRectMake(-menuFrame.size.width, menuFrame.origin.y, menuFrame.size.width, menuFrame.size.height); 241 | otherView.alpha = 1; 242 | ov.alpha = 1; 243 | } completion:^(BOOL finished) { 244 | 245 | BOOL canceled = [status.context transitionWasCancelled]; 246 | 247 | if (!canceled) { 248 | [self.bottomView removeFromSuperview]; 249 | }else{ 250 | 251 | if ([menuView isKindOfClass:[UIScrollView class]]) { 252 | [menuView removeFromSuperview]; 253 | [self addTapGestureToView:ov]; 254 | [self.bottomView addSubview:menuView]; 255 | [containerView insertSubview:self.bottomView aboveSubview:ov]; 256 | }else{ 257 | [self addTapGestureToView:ov]; 258 | } 259 | } 260 | 261 | completion(); 262 | }]; 263 | } 264 | 265 | #pragma mark - private 266 | 267 | - (void)updateShapeLayer { 268 | self.shapeLayer.path = [self currentPath]; 269 | } 270 | 271 | - (CGPathRef)currentPath{ 272 | UIBezierPath *bezierPath = [UIBezierPath new]; 273 | 274 | [bezierPath moveToPoint:CGPointZero]; 275 | [bezierPath addLineToPoint:CGPointMake(self.controlViews[0].center.x, 0)]; 276 | [bezierPath addCurveToPoint:self.controlViews[2].center controlPoint1:self.controlViews[0].center controlPoint2:self.controlViews[1].center]; 277 | [bezierPath addCurveToPoint:self.controlViews[4].center controlPoint1:self.controlViews[3].center controlPoint2:self.controlViews[4].center]; 278 | [bezierPath addCurveToPoint:self.controlViews[6].center controlPoint1:self.controlViews[4].center controlPoint2:self.controlViews[5].center]; 279 | [bezierPath addLineToPoint:CGPointMake(0, self.controlViews[7].center.y)]; 280 | [bezierPath closePath]; 281 | 282 | return bezierPath.CGPath; 283 | } 284 | 285 | - (void)moveControlPointsToPoint:(CGPoint )position waveWidth:(CGFloat)waveWidth 286 | { 287 | CGFloat height = self.controlViews[7].center.y; 288 | 289 | CGFloat minTopY = MIN((position.y - height / 2) * 0.28, 0); 290 | CGFloat maxBottomY = MAX(height + (position.y - height / 2) * 0.28, height); 291 | 292 | CGFloat leftPartWidth = position.y - minTopY; 293 | CGFloat rightPartWidth = maxBottomY - position.y; 294 | 295 | self.controlViews[0].center = CGPointMake(position.x, minTopY); 296 | self.controlViews[1].center = CGPointMake(position.x, minTopY + leftPartWidth * 0.44); 297 | self.controlViews[2].center = CGPointMake(position.x + waveWidth * 0.64, minTopY + leftPartWidth * 0.71); 298 | self.controlViews[3].center = CGPointMake(position.x + waveWidth * 1.36, position.y); 299 | self.controlViews[4].center = CGPointMake(position.x + waveWidth * 0.64, maxBottomY - rightPartWidth * 0.71); 300 | self.controlViews[5].center = CGPointMake(position.x, maxBottomY - (rightPartWidth * 0.44)); 301 | self.controlViews[6].center = CGPointMake(position.x, height); 302 | 303 | } 304 | 305 | #pragma mark - FlowingMenuTransitionManager + UIGestureRecognizer 306 | 307 | - (void)addTapGestureToView:(UIView*)view { 308 | UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapToDismissAction:)]; 309 | tapGesture.numberOfTapsRequired = 1; 310 | [view addGestureRecognizer:tapGesture]; 311 | } 312 | 313 | -(void)setInteractiveDismissView:(UIView *)view { 314 | UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panToDismissAction:)]; 315 | panGesture.maximumNumberOfTouches = 1; 316 | [view addGestureRecognizer:panGesture]; 317 | } 318 | 319 | -(void)setInteractivePresentationView:(UIView *)view{ 320 | UIScreenEdgePanGestureRecognizer *screenEdgePanGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(panToPresentAction:)]; 321 | screenEdgePanGesture.edges = UIRectEdgeLeft; 322 | [view addGestureRecognizer:screenEdgePanGesture]; 323 | } 324 | 325 | -(void)tapToDismissAction:(UITapGestureRecognizer *)tapGesture { 326 | if (self.toVCDelegate && [self.toVCDelegate respondsToSelector:@selector(flowingMenuNeedsDismissMenu)]) { 327 | [self.toVCDelegate flowingMenuNeedsDismissMenu]; 328 | } 329 | } 330 | 331 | -(void)panToDismissAction:(UIPanGestureRecognizer *)panGesture { 332 | UIView *view = panGesture.view; 333 | 334 | CGFloat menuWidth = 0.0; 335 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(widthOfMenuView:)]) { 336 | menuWidth = [self.fromVCDelegate widthOfMenuView:view]; 337 | }else{ 338 | menuWidth = [self widthOfMenuView:view]; 339 | } 340 | CGPoint translation = [panGesture translationInView:view]; 341 | 342 | CGFloat percentage = MIN(MAX(translation.x / menuWidth * -1, 0), 1); 343 | 344 | if (panGesture.state == UIGestureRecognizerStateBegan) { 345 | self.interactive = YES; 346 | // Asking the delegate the dismiss the menu 347 | if (self.toVCDelegate && [self.toVCDelegate respondsToSelector:@selector(flowingMenuNeedsDismissMenu)]) { 348 | [self.toVCDelegate flowingMenuNeedsDismissMenu]; 349 | } 350 | }else if (panGesture.state == UIGestureRecognizerStateChanged){ 351 | [self updateInteractiveTransition:percentage]; 352 | }else if(panGesture.state == UIGestureRecognizerStateCancelled || panGesture.state == UIGestureRecognizerStateEnded) { 353 | self.interactive = NO; 354 | if (percentage > 0.2) { 355 | [self finishInteractiveTransition]; 356 | }else{ 357 | [self cancelInteractiveTransition]; 358 | } 359 | } 360 | } 361 | 362 | -(void)panToPresentAction:(UIScreenEdgePanGestureRecognizer *)panGesture { 363 | UIView *view = panGesture.view; 364 | CGPoint translation = [panGesture translationInView:view]; 365 | CGFloat yLocation = [panGesture locationInView:view].y; 366 | 367 | CGFloat menuWidth = 0.0; 368 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(widthOfMenuView:)]) { 369 | menuWidth = [self.fromVCDelegate widthOfMenuView:view]; 370 | }else{ 371 | menuWidth = [self widthOfMenuView:view]; 372 | } 373 | 374 | CGFloat percentage = MIN(MAX(translation.x / (menuWidth/2), 0), 1); 375 | 376 | if (panGesture.state == UIGestureRecognizerStateBegan) { 377 | self.interactive = YES; 378 | // Asking the delegate the present the menu 379 | if (self.fromVCDelegate && [self.fromVCDelegate respondsToSelector:@selector(flowingMenuNeedsPresentMenu)]) { 380 | [self.fromVCDelegate flowingMenuNeedsPresentMenu]; 381 | } 382 | }else if (panGesture.state == UIGestureRecognizerStateChanged){ 383 | [self updateInteractiveTransition:percentage]; 384 | 385 | CGFloat waveWidth = translation.x * 0.9; 386 | CGFloat left = waveWidth * 0.1; 387 | 388 | // Update the control points 389 | [self moveControlPointsToPoint:CGPointMake(left, yLocation) waveWidth:waveWidth]; 390 | [self updateShapeLayer]; 391 | }else /*if(panGesture.state == UIGestureRecognizerStateCancelled || panGesture.state == UIGestureRecognizerStateEnded)*/{ 392 | self.displayLink.paused = NO; 393 | if( percentage < 1 ){ 394 | self.interactive = NO; 395 | [self moveControlPointsToPoint:CGPointMake(0, yLocation) waveWidth:0]; 396 | [self cancelInteractiveTransition]; 397 | } 398 | else { 399 | [self finishInteractiveTransition]; 400 | } 401 | 402 | } 403 | } 404 | 405 | 406 | #pragma mark - FlowingMenuDelegate 407 | 408 | - (CGFloat)widthOfMenuView:(UIView *)menuView 409 | { 410 | return menuView.bounds.size.width * 2 / 3; 411 | } 412 | 413 | -(UIColor *)colorOfElasticShapeInFlowingMenu:(UIView *)menuView 414 | { 415 | return [UIColor cyanColor]; 416 | } 417 | 418 | #pragma mark - UIViewControllerTransitioningDelegate 419 | 420 | -(id)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source 421 | { 422 | self.animationMode = AnimationModePresentation; 423 | return self; 424 | } 425 | 426 | -(id)animationControllerForDismissedController:(UIViewController *)dismissed 427 | { 428 | self.animationMode = AnimationModeDismissal; 429 | return self; 430 | } 431 | 432 | - (nullable id )interactionControllerForPresentation:(id )animator 433 | { 434 | self.animationMode = AnimationModePresentation; 435 | return self.interactive ? self : nil; 436 | } 437 | 438 | -(id)interactionControllerForDismissal:(id)animator 439 | { 440 | self.animationMode = AnimationModeDismissal; 441 | return self.interactive ? self : nil; 442 | } 443 | 444 | #pragma mark - UIViewControllerAnimatedTransitioning 445 | 446 | - (void)animateTransition:(id)transitionContext 447 | { 448 | UIViewController *fromVC = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; 449 | UIViewController *toVC = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; 450 | 451 | UIView *containerView = transitionContext.containerView; 452 | UIView *menuView = (self.animationMode == AnimationModePresentation) ? toVC.view : fromVC.view; 453 | UIView *otherView = (self.animationMode == AnimationModePresentation) ? fromVC.view : toVC.view; ; 454 | 455 | FlowingMenuTransitionStatus *status = [[FlowingMenuTransitionStatus alloc] initWithContext:transitionContext]; 456 | 457 | if (self.animationMode == AnimationModePresentation) { 458 | [self view:otherView presentMenuView:menuView containerView:containerView status:status duration:[self transitionDuration:transitionContext] completion:^{ 459 | BOOL canceled = [transitionContext transitionWasCancelled]; 460 | [transitionContext completeTransition:!canceled]; 461 | 462 | if (!canceled) { 463 | [[UIApplication sharedApplication].keyWindow insertSubview:fromVC.view atIndex:0]; 464 | } 465 | }]; 466 | }else{ 467 | [self view:otherView dismissMenuView:menuView containerView:containerView status:status duration:[self transitionDuration:transitionContext] completion:^{ 468 | BOOL canceled = [transitionContext transitionWasCancelled]; 469 | [transitionContext completeTransition:!canceled]; 470 | 471 | if (!canceled) { 472 | [[UIApplication sharedApplication].keyWindow insertSubview:fromVC.view atIndex:0]; 473 | } 474 | }]; 475 | } 476 | } 477 | - (NSTimeInterval)transitionDuration:(nullable id )transitionContext 478 | { 479 | return self.interactive ? 0.6 : 0.25; 480 | } 481 | 482 | @end 483 | -------------------------------------------------------------------------------- /Source/FlowingMenuTransitionStatus.h: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionStatus.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | /** 11 | The FlowingMenuTransitionStatus object aims to make the transition manager 12 | testable by providing a concevient way to access the 13 | `UIViewControllerContextTransitioning` `transitionWasCancelled` method. 14 | */ 15 | @interface FlowingMenuTransitionStatus : NSObject 16 | 17 | @property (readonly,nonatomic) id context; 18 | /// Initializer for testing purpose. 19 | -(instancetype)initWithCancelledOrNot:(BOOL)cancelled; 20 | 21 | /// Initializer for running purpose. 22 | - (instancetype)initWithContext:(id)context; 23 | 24 | /** 25 | Returns a Boolean value indicating whether the transition was canceled. 26 | 27 | true if the transition was canceled or false if it is ongoing or finished 28 | normally. 29 | 30 | - returns: true if the transition was canceled or NO if it is ongoing or 31 | finished normally. 32 | */ 33 | - (BOOL)transitionWasCancelled; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Source/FlowingMenuTransitionStatus.m: -------------------------------------------------------------------------------- 1 | // 2 | // FlowingMenuTransitionStatus.m 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/11. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import "FlowingMenuTransitionStatus.h" 10 | 11 | @interface FlowingMenuTransitionStatus () 12 | @property (readonly,nonatomic) BOOL cancelled; 13 | @end 14 | @implementation FlowingMenuTransitionStatus 15 | 16 | - (instancetype)initWithCancelledOrNot:(BOOL)cancelled 17 | { 18 | self = [super init]; 19 | if (self) { 20 | self->_context = nil; 21 | self->_cancelled = cancelled; 22 | } 23 | return self; 24 | } 25 | 26 | - (instancetype)initWithContext:(id)context 27 | { 28 | self = [super init]; 29 | if (self) { 30 | self->_context = context; 31 | self->_cancelled = NO; 32 | } 33 | return self; 34 | } 35 | 36 | - (BOOL)transitionWasCancelled 37 | { 38 | return self.context ? [self.context transitionWasCancelled] : self.cancelled; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Source/FromViewControllerNeedsConform.h: -------------------------------------------------------------------------------- 1 | // 2 | // FromViewControllerNeedsConform.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol FromViewControllerNeedsConform 12 | 13 | @optional 14 | /** 15 | Called by the flowing menu transition manager when it needs to display the 16 | menu. 17 | 18 | - parameter menuView: The menu view which will be displayed. 19 | - returns: The width of the menu view. Outside the menu view a black overlay 20 | will be displayed. 21 | */ 22 | -(CGFloat)widthOfMenuView:(UIView *)menuView; 23 | 24 | 25 | /** 26 | Asks the delegate the color of the shape drawn during an interactive 27 | transition. 28 | 29 | - returns: The shape color. If nil it will use the menu background color and 30 | if menu has no background color, the shape will be black. 31 | */ 32 | -(UIColor *)colorOfElasticShapeInFlowingMenu:(UIView *)menuView; 33 | 34 | /** 35 | Called by the flowing menu transition manager when the interactive transition 36 | begins its presentation. You should implement this methods to present your 37 | menu view. 38 | 39 | - parameter flowingMenu: The flowing menu transition manager which needs 40 | present the menu. 41 | */ 42 | - (void)flowingMenuNeedsPresentMenu; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Source/ToViewControllerNeedsConform.h: -------------------------------------------------------------------------------- 1 | // 2 | // ToViewControllerNeedsConform.h 3 | // WaveInteractive 4 | // 5 | // Created by cheaterhu on 2017/4/12. 6 | // Copyright © 2017年 cheaterhu. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol ToViewControllerNeedsConform 12 | /** 13 | Called by the flowing menu transition manager when the interactive transition 14 | begins its dismissal. You should implement this methods to dismiss your menu 15 | view. 16 | 17 | - parameter flowingMenu: The flowing menu transition manager which needs 18 | dismiss the menu. 19 | */ 20 | -(void)flowingMenuNeedsDismissMenu; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /YLFlowingMenu.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'YLFlowingMenu' 3 | s.version = '1.0.0' 4 | s.license = 'MIT' 5 | s.summary = 'Interactive view transition to display menus with flowing and bouncing effects in Swift' 6 | s.homepage = 'https://github.com/yannickl/YLFlowingMenu.git' 7 | s.social_media_url = 'https://twitter.com/yannickloriot' 8 | s.authors = { 'Yannick Loriot' => 'contact@yannickloriot.com' } 9 | s.source = { :git => 'https://github.com/yannickl/YLFlowingMenu.git', :tag => s.version } 10 | s.screenshot = 'http://yannickloriot.com/resources/flowingmenu.gif' 11 | 12 | s.ios.deployment_target = '8.0' 13 | s.ios.frameworks = 'UIKit', 'QuartzCore' 14 | 15 | s.source_files = 'Sources/*.*' 16 | s.requires_arc = true 17 | end 18 | --------------------------------------------------------------------------------