├── Menu.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── Menu.xccheckout │ └── xcuserdata │ │ └── fengchuanxiang.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── fcx.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── Menu.xcscheme │ │ └── xcschememanagement.plist │ └── fengchuanxiang.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── Menu.xcscheme │ └── xcschememanagement.plist ├── Menu ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── FCXPathButtonItem.h ├── FCXPathButtonItem.m ├── FCXPathMenu.h ├── FCXPathMenu.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── PathEdit.imageset │ │ ├── Contents.json │ │ └── PathEdit@2x.png │ ├── PathMain.imageset │ │ ├── Contents.json │ │ └── PathMain@2x.png │ └── menu.imageset │ │ ├── Contents.json │ │ ├── menu@2x.png │ │ └── menu@3x.png ├── Info.plist ├── MenuPopover.h ├── MenuPopover.m ├── MenuScrollView.h ├── MenuScrollView.m ├── ViewController.h ├── ViewController.m └── main.m ├── MenuTests ├── Info.plist └── MenuTests.m ├── README.md └── menuDemo@3x.png /Menu.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 197DF9AB1B6B14AD000E812C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 197DF9AA1B6B14AD000E812C /* main.m */; }; 11 | 197DF9AE1B6B14AD000E812C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 197DF9AD1B6B14AD000E812C /* AppDelegate.m */; }; 12 | 197DF9B11B6B14AD000E812C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 197DF9B01B6B14AD000E812C /* ViewController.m */; }; 13 | 197DF9B41B6B14AD000E812C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 197DF9B21B6B14AD000E812C /* Main.storyboard */; }; 14 | 197DF9B61B6B14AD000E812C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 197DF9B51B6B14AD000E812C /* Images.xcassets */; }; 15 | 197DF9B91B6B14AD000E812C /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 197DF9B71B6B14AD000E812C /* LaunchScreen.xib */; }; 16 | 197DF9C51B6B14AD000E812C /* MenuTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 197DF9C41B6B14AD000E812C /* MenuTests.m */; }; 17 | 19A36DD41B6B452D008B7464 /* MenuScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 19A36DD31B6B452D008B7464 /* MenuScrollView.m */; }; 18 | 19A36DD71B6B6225008B7464 /* MenuPopover.m in Sources */ = {isa = PBXBuildFile; fileRef = 19A36DD61B6B6225008B7464 /* MenuPopover.m */; }; 19 | 8AA89D901B99277600E754B5 /* FCXPathMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AA89D8F1B99277600E754B5 /* FCXPathMenu.m */; }; 20 | 8AA89D931B99278E00E754B5 /* FCXPathButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AA89D921B99278E00E754B5 /* FCXPathButtonItem.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 197DF9BF1B6B14AD000E812C /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 197DF99D1B6B14AD000E812C /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 197DF9A41B6B14AD000E812C; 29 | remoteInfo = Menu; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 197DF9A51B6B14AD000E812C /* Menu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Menu.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 197DF9A91B6B14AD000E812C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 197DF9AA1B6B14AD000E812C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 37 | 197DF9AC1B6B14AD000E812C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 197DF9AD1B6B14AD000E812C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 197DF9AF1B6B14AD000E812C /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 40 | 197DF9B01B6B14AD000E812C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 41 | 197DF9B31B6B14AD000E812C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 197DF9B51B6B14AD000E812C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 43 | 197DF9B81B6B14AD000E812C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 44 | 197DF9BE1B6B14AD000E812C /* MenuTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MenuTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 197DF9C31B6B14AD000E812C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 197DF9C41B6B14AD000E812C /* MenuTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MenuTests.m; sourceTree = ""; }; 47 | 19A36DD21B6B452D008B7464 /* MenuScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuScrollView.h; sourceTree = ""; }; 48 | 19A36DD31B6B452D008B7464 /* MenuScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuScrollView.m; sourceTree = ""; }; 49 | 19A36DD51B6B6225008B7464 /* MenuPopover.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MenuPopover.h; sourceTree = ""; }; 50 | 19A36DD61B6B6225008B7464 /* MenuPopover.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MenuPopover.m; sourceTree = ""; }; 51 | 8AA89D8E1B99277600E754B5 /* FCXPathMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FCXPathMenu.h; sourceTree = ""; }; 52 | 8AA89D8F1B99277600E754B5 /* FCXPathMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FCXPathMenu.m; sourceTree = ""; }; 53 | 8AA89D911B99278E00E754B5 /* FCXPathButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FCXPathButtonItem.h; sourceTree = ""; }; 54 | 8AA89D921B99278E00E754B5 /* FCXPathButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FCXPathButtonItem.m; sourceTree = ""; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 197DF9A21B6B14AD000E812C /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | 197DF9BB1B6B14AD000E812C /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | 197DF99C1B6B14AD000E812C = { 76 | isa = PBXGroup; 77 | children = ( 78 | 197DF9A71B6B14AD000E812C /* Menu */, 79 | 197DF9C11B6B14AD000E812C /* MenuTests */, 80 | 197DF9A61B6B14AD000E812C /* Products */, 81 | ); 82 | sourceTree = ""; 83 | }; 84 | 197DF9A61B6B14AD000E812C /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 197DF9A51B6B14AD000E812C /* Menu.app */, 88 | 197DF9BE1B6B14AD000E812C /* MenuTests.xctest */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | 197DF9A71B6B14AD000E812C /* Menu */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 197DF9AC1B6B14AD000E812C /* AppDelegate.h */, 97 | 197DF9AD1B6B14AD000E812C /* AppDelegate.m */, 98 | 197DF9AF1B6B14AD000E812C /* ViewController.h */, 99 | 197DF9B01B6B14AD000E812C /* ViewController.m */, 100 | 19A36DD51B6B6225008B7464 /* MenuPopover.h */, 101 | 19A36DD61B6B6225008B7464 /* MenuPopover.m */, 102 | 19A36DD21B6B452D008B7464 /* MenuScrollView.h */, 103 | 19A36DD31B6B452D008B7464 /* MenuScrollView.m */, 104 | 8AA89D8E1B99277600E754B5 /* FCXPathMenu.h */, 105 | 8AA89D8F1B99277600E754B5 /* FCXPathMenu.m */, 106 | 8AA89D911B99278E00E754B5 /* FCXPathButtonItem.h */, 107 | 8AA89D921B99278E00E754B5 /* FCXPathButtonItem.m */, 108 | 197DF9B21B6B14AD000E812C /* Main.storyboard */, 109 | 197DF9B51B6B14AD000E812C /* Images.xcassets */, 110 | 197DF9B71B6B14AD000E812C /* LaunchScreen.xib */, 111 | 197DF9A81B6B14AD000E812C /* Supporting Files */, 112 | ); 113 | path = Menu; 114 | sourceTree = ""; 115 | }; 116 | 197DF9A81B6B14AD000E812C /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 197DF9A91B6B14AD000E812C /* Info.plist */, 120 | 197DF9AA1B6B14AD000E812C /* main.m */, 121 | ); 122 | name = "Supporting Files"; 123 | sourceTree = ""; 124 | }; 125 | 197DF9C11B6B14AD000E812C /* MenuTests */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 197DF9C41B6B14AD000E812C /* MenuTests.m */, 129 | 197DF9C21B6B14AD000E812C /* Supporting Files */, 130 | ); 131 | path = MenuTests; 132 | sourceTree = ""; 133 | }; 134 | 197DF9C21B6B14AD000E812C /* Supporting Files */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 197DF9C31B6B14AD000E812C /* Info.plist */, 138 | ); 139 | name = "Supporting Files"; 140 | sourceTree = ""; 141 | }; 142 | /* End PBXGroup section */ 143 | 144 | /* Begin PBXNativeTarget section */ 145 | 197DF9A41B6B14AD000E812C /* Menu */ = { 146 | isa = PBXNativeTarget; 147 | buildConfigurationList = 197DF9C81B6B14AD000E812C /* Build configuration list for PBXNativeTarget "Menu" */; 148 | buildPhases = ( 149 | 197DF9A11B6B14AD000E812C /* Sources */, 150 | 197DF9A21B6B14AD000E812C /* Frameworks */, 151 | 197DF9A31B6B14AD000E812C /* Resources */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | ); 157 | name = Menu; 158 | productName = Menu; 159 | productReference = 197DF9A51B6B14AD000E812C /* Menu.app */; 160 | productType = "com.apple.product-type.application"; 161 | }; 162 | 197DF9BD1B6B14AD000E812C /* MenuTests */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 197DF9CB1B6B14AD000E812C /* Build configuration list for PBXNativeTarget "MenuTests" */; 165 | buildPhases = ( 166 | 197DF9BA1B6B14AD000E812C /* Sources */, 167 | 197DF9BB1B6B14AD000E812C /* Frameworks */, 168 | 197DF9BC1B6B14AD000E812C /* Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | 197DF9C01B6B14AD000E812C /* PBXTargetDependency */, 174 | ); 175 | name = MenuTests; 176 | productName = MenuTests; 177 | productReference = 197DF9BE1B6B14AD000E812C /* MenuTests.xctest */; 178 | productType = "com.apple.product-type.bundle.unit-test"; 179 | }; 180 | /* End PBXNativeTarget section */ 181 | 182 | /* Begin PBXProject section */ 183 | 197DF99D1B6B14AD000E812C /* Project object */ = { 184 | isa = PBXProject; 185 | attributes = { 186 | CLASSPREFIX = FCX; 187 | LastUpgradeCheck = 0640; 188 | ORGANIZATIONNAME = fcx; 189 | TargetAttributes = { 190 | 197DF9A41B6B14AD000E812C = { 191 | CreatedOnToolsVersion = 6.4; 192 | }; 193 | 197DF9BD1B6B14AD000E812C = { 194 | CreatedOnToolsVersion = 6.4; 195 | TestTargetID = 197DF9A41B6B14AD000E812C; 196 | }; 197 | }; 198 | }; 199 | buildConfigurationList = 197DF9A01B6B14AD000E812C /* Build configuration list for PBXProject "Menu" */; 200 | compatibilityVersion = "Xcode 3.2"; 201 | developmentRegion = English; 202 | hasScannedForEncodings = 0; 203 | knownRegions = ( 204 | en, 205 | Base, 206 | ); 207 | mainGroup = 197DF99C1B6B14AD000E812C; 208 | productRefGroup = 197DF9A61B6B14AD000E812C /* Products */; 209 | projectDirPath = ""; 210 | projectRoot = ""; 211 | targets = ( 212 | 197DF9A41B6B14AD000E812C /* Menu */, 213 | 197DF9BD1B6B14AD000E812C /* MenuTests */, 214 | ); 215 | }; 216 | /* End PBXProject section */ 217 | 218 | /* Begin PBXResourcesBuildPhase section */ 219 | 197DF9A31B6B14AD000E812C /* Resources */ = { 220 | isa = PBXResourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | 197DF9B41B6B14AD000E812C /* Main.storyboard in Resources */, 224 | 197DF9B91B6B14AD000E812C /* LaunchScreen.xib in Resources */, 225 | 197DF9B61B6B14AD000E812C /* Images.xcassets in Resources */, 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | 197DF9BC1B6B14AD000E812C /* Resources */ = { 230 | isa = PBXResourcesBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | }; 236 | /* End PBXResourcesBuildPhase section */ 237 | 238 | /* Begin PBXSourcesBuildPhase section */ 239 | 197DF9A11B6B14AD000E812C /* Sources */ = { 240 | isa = PBXSourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | 8AA89D931B99278E00E754B5 /* FCXPathButtonItem.m in Sources */, 244 | 19A36DD71B6B6225008B7464 /* MenuPopover.m in Sources */, 245 | 8AA89D901B99277600E754B5 /* FCXPathMenu.m in Sources */, 246 | 197DF9B11B6B14AD000E812C /* ViewController.m in Sources */, 247 | 19A36DD41B6B452D008B7464 /* MenuScrollView.m in Sources */, 248 | 197DF9AE1B6B14AD000E812C /* AppDelegate.m in Sources */, 249 | 197DF9AB1B6B14AD000E812C /* main.m in Sources */, 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | }; 253 | 197DF9BA1B6B14AD000E812C /* Sources */ = { 254 | isa = PBXSourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | 197DF9C51B6B14AD000E812C /* MenuTests.m in Sources */, 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | }; 261 | /* End PBXSourcesBuildPhase section */ 262 | 263 | /* Begin PBXTargetDependency section */ 264 | 197DF9C01B6B14AD000E812C /* PBXTargetDependency */ = { 265 | isa = PBXTargetDependency; 266 | target = 197DF9A41B6B14AD000E812C /* Menu */; 267 | targetProxy = 197DF9BF1B6B14AD000E812C /* PBXContainerItemProxy */; 268 | }; 269 | /* End PBXTargetDependency section */ 270 | 271 | /* Begin PBXVariantGroup section */ 272 | 197DF9B21B6B14AD000E812C /* Main.storyboard */ = { 273 | isa = PBXVariantGroup; 274 | children = ( 275 | 197DF9B31B6B14AD000E812C /* Base */, 276 | ); 277 | name = Main.storyboard; 278 | sourceTree = ""; 279 | }; 280 | 197DF9B71B6B14AD000E812C /* LaunchScreen.xib */ = { 281 | isa = PBXVariantGroup; 282 | children = ( 283 | 197DF9B81B6B14AD000E812C /* Base */, 284 | ); 285 | name = LaunchScreen.xib; 286 | sourceTree = ""; 287 | }; 288 | /* End PBXVariantGroup section */ 289 | 290 | /* Begin XCBuildConfiguration section */ 291 | 197DF9C61B6B14AD000E812C /* Debug */ = { 292 | isa = XCBuildConfiguration; 293 | buildSettings = { 294 | ALWAYS_SEARCH_USER_PATHS = NO; 295 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 296 | CLANG_CXX_LIBRARY = "libc++"; 297 | CLANG_ENABLE_MODULES = YES; 298 | CLANG_ENABLE_OBJC_ARC = YES; 299 | CLANG_WARN_BOOL_CONVERSION = YES; 300 | CLANG_WARN_CONSTANT_CONVERSION = YES; 301 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 302 | CLANG_WARN_EMPTY_BODY = YES; 303 | CLANG_WARN_ENUM_CONVERSION = YES; 304 | CLANG_WARN_INT_CONVERSION = YES; 305 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 306 | CLANG_WARN_UNREACHABLE_CODE = YES; 307 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 308 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 309 | COPY_PHASE_STRIP = NO; 310 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 311 | ENABLE_STRICT_OBJC_MSGSEND = YES; 312 | GCC_C_LANGUAGE_STANDARD = gnu99; 313 | GCC_DYNAMIC_NO_PIC = NO; 314 | GCC_NO_COMMON_BLOCKS = YES; 315 | GCC_OPTIMIZATION_LEVEL = 0; 316 | GCC_PREPROCESSOR_DEFINITIONS = ( 317 | "DEBUG=1", 318 | "$(inherited)", 319 | ); 320 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 321 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 322 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 323 | GCC_WARN_UNDECLARED_SELECTOR = YES; 324 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 325 | GCC_WARN_UNUSED_FUNCTION = YES; 326 | GCC_WARN_UNUSED_VARIABLE = YES; 327 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 328 | MTL_ENABLE_DEBUG_INFO = YES; 329 | ONLY_ACTIVE_ARCH = YES; 330 | SDKROOT = iphoneos; 331 | }; 332 | name = Debug; 333 | }; 334 | 197DF9C71B6B14AD000E812C /* Release */ = { 335 | isa = XCBuildConfiguration; 336 | buildSettings = { 337 | ALWAYS_SEARCH_USER_PATHS = NO; 338 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 339 | CLANG_CXX_LIBRARY = "libc++"; 340 | CLANG_ENABLE_MODULES = YES; 341 | CLANG_ENABLE_OBJC_ARC = YES; 342 | CLANG_WARN_BOOL_CONVERSION = YES; 343 | CLANG_WARN_CONSTANT_CONVERSION = YES; 344 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 345 | CLANG_WARN_EMPTY_BODY = YES; 346 | CLANG_WARN_ENUM_CONVERSION = YES; 347 | CLANG_WARN_INT_CONVERSION = YES; 348 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 349 | CLANG_WARN_UNREACHABLE_CODE = YES; 350 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 351 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 352 | COPY_PHASE_STRIP = NO; 353 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 354 | ENABLE_NS_ASSERTIONS = NO; 355 | ENABLE_STRICT_OBJC_MSGSEND = YES; 356 | GCC_C_LANGUAGE_STANDARD = gnu99; 357 | GCC_NO_COMMON_BLOCKS = YES; 358 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 359 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 360 | GCC_WARN_UNDECLARED_SELECTOR = YES; 361 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 362 | GCC_WARN_UNUSED_FUNCTION = YES; 363 | GCC_WARN_UNUSED_VARIABLE = YES; 364 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 365 | MTL_ENABLE_DEBUG_INFO = NO; 366 | SDKROOT = iphoneos; 367 | VALIDATE_PRODUCT = YES; 368 | }; 369 | name = Release; 370 | }; 371 | 197DF9C91B6B14AD000E812C /* Debug */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 375 | INFOPLIST_FILE = Menu/Info.plist; 376 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 377 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 378 | PRODUCT_NAME = "$(TARGET_NAME)"; 379 | }; 380 | name = Debug; 381 | }; 382 | 197DF9CA1B6B14AD000E812C /* Release */ = { 383 | isa = XCBuildConfiguration; 384 | buildSettings = { 385 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 386 | INFOPLIST_FILE = Menu/Info.plist; 387 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 388 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 389 | PRODUCT_NAME = "$(TARGET_NAME)"; 390 | }; 391 | name = Release; 392 | }; 393 | 197DF9CC1B6B14AD000E812C /* Debug */ = { 394 | isa = XCBuildConfiguration; 395 | buildSettings = { 396 | BUNDLE_LOADER = "$(TEST_HOST)"; 397 | FRAMEWORK_SEARCH_PATHS = ( 398 | "$(SDKROOT)/Developer/Library/Frameworks", 399 | "$(inherited)", 400 | ); 401 | GCC_PREPROCESSOR_DEFINITIONS = ( 402 | "DEBUG=1", 403 | "$(inherited)", 404 | ); 405 | INFOPLIST_FILE = MenuTests/Info.plist; 406 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 407 | PRODUCT_NAME = "$(TARGET_NAME)"; 408 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Menu.app/Menu"; 409 | }; 410 | name = Debug; 411 | }; 412 | 197DF9CD1B6B14AD000E812C /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | BUNDLE_LOADER = "$(TEST_HOST)"; 416 | FRAMEWORK_SEARCH_PATHS = ( 417 | "$(SDKROOT)/Developer/Library/Frameworks", 418 | "$(inherited)", 419 | ); 420 | INFOPLIST_FILE = MenuTests/Info.plist; 421 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 422 | PRODUCT_NAME = "$(TARGET_NAME)"; 423 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Menu.app/Menu"; 424 | }; 425 | name = Release; 426 | }; 427 | /* End XCBuildConfiguration section */ 428 | 429 | /* Begin XCConfigurationList section */ 430 | 197DF9A01B6B14AD000E812C /* Build configuration list for PBXProject "Menu" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | 197DF9C61B6B14AD000E812C /* Debug */, 434 | 197DF9C71B6B14AD000E812C /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | 197DF9C81B6B14AD000E812C /* Build configuration list for PBXNativeTarget "Menu" */ = { 440 | isa = XCConfigurationList; 441 | buildConfigurations = ( 442 | 197DF9C91B6B14AD000E812C /* Debug */, 443 | 197DF9CA1B6B14AD000E812C /* Release */, 444 | ); 445 | defaultConfigurationIsVisible = 0; 446 | defaultConfigurationName = Release; 447 | }; 448 | 197DF9CB1B6B14AD000E812C /* Build configuration list for PBXNativeTarget "MenuTests" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | 197DF9CC1B6B14AD000E812C /* Debug */, 452 | 197DF9CD1B6B14AD000E812C /* Release */, 453 | ); 454 | defaultConfigurationIsVisible = 0; 455 | defaultConfigurationName = Release; 456 | }; 457 | /* End XCConfigurationList section */ 458 | }; 459 | rootObject = 197DF99D1B6B14AD000E812C /* Project object */; 460 | } 461 | -------------------------------------------------------------------------------- /Menu.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Menu.xcodeproj/project.xcworkspace/xcshareddata/Menu.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | A915DBC3-4160-4D94-9F10-C30746C676A9 9 | IDESourceControlProjectName 10 | Menu 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 7866473DBEFC6B4CD20CA8A3652FDAF16BFEFFD2 14 | https://github.com/fengchuanxiang/Menu.git 15 | 16 | IDESourceControlProjectPath 17 | Menu.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 7866473DBEFC6B4CD20CA8A3652FDAF16BFEFFD2 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/fengchuanxiang/Menu.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 7866473DBEFC6B4CD20CA8A3652FDAF16BFEFFD2 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 7866473DBEFC6B4CD20CA8A3652FDAF16BFEFFD2 36 | IDESourceControlWCCName 37 | Menu 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Menu.xcodeproj/project.xcworkspace/xcuserdata/fengchuanxiang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengchuanxiang/Menu/32dd91a8fc3130c357b32c02eefc7df2f47f32d0/Menu.xcodeproj/project.xcworkspace/xcuserdata/fengchuanxiang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Menu.xcodeproj/xcuserdata/fcx.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Menu.xcodeproj/xcuserdata/fcx.xcuserdatad/xcschemes/Menu.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /Menu.xcodeproj/xcuserdata/fcx.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Menu.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 197DF9A41B6B14AD000E812C 16 | 17 | primary 18 | 19 | 20 | 197DF9BD1B6B14AD000E812C 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Menu.xcodeproj/xcuserdata/fengchuanxiang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Menu.xcodeproj/xcuserdata/fengchuanxiang.xcuserdatad/xcschemes/Menu.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 90 | 91 | 95 | 96 | 97 | 98 | 104 | 106 | 112 | 113 | 114 | 115 | 117 | 118 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /Menu.xcodeproj/xcuserdata/fengchuanxiang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Menu.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 197DF9A41B6B14AD000E812C 16 | 17 | primary 18 | 19 | 20 | 197DF9BD1B6B14AD000E812C 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Menu/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. 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 | -------------------------------------------------------------------------------- /Menu/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. 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 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Menu/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Menu/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 | -------------------------------------------------------------------------------- /Menu/FCXPathButtonItem.h: -------------------------------------------------------------------------------- 1 | // 2 | // FCXPathButtonItem.h 3 | // Menu 4 | // 5 | // Created by 冯 传祥 on 15/9/4. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FCXPathButtonItem : UIButton 12 | 13 | 14 | //展开时的角度 15 | @property (nonatomic, unsafe_unretained) double expandAngle; 16 | 17 | //paht展开动画时,按照开始点、远点、近点、终点的顺序进行 18 | @property (nonatomic, unsafe_unretained) CGPoint startPoint; 19 | @property (nonatomic, unsafe_unretained) CGPoint farPoint; 20 | @property (nonatomic, unsafe_unretained) CGPoint nearPoint; 21 | @property (nonatomic, unsafe_unretained) CGPoint endPoint; 22 | 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Menu/FCXPathButtonItem.m: -------------------------------------------------------------------------------- 1 | // 2 | // FCXPathButtonItem.m 3 | // Menu 4 | // 5 | // Created by 冯 传祥 on 15/9/4. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import "FCXPathButtonItem.h" 10 | 11 | @implementation FCXPathButtonItem 12 | 13 | /* 14 | // Only override drawRect: if you perform custom drawing. 15 | // An empty implementation adversely affects performance during animation. 16 | - (void)drawRect:(CGRect)rect { 17 | // Drawing code 18 | } 19 | */ 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Menu/FCXPathMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // FCXPathMenu.h 3 | // Menu 4 | // 5 | // Created by 冯 传祥 on 15/9/4. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | 12 | typedef void (^MenuClickBlock)(NSInteger buttonIndex); 13 | 14 | @interface FCXPathMenu : UIView 15 | 16 | @property (nonatomic, strong) UIButton *mainButton; 17 | @property (nonatomic, assign, getter=isExpanding) BOOL expanding; 18 | @property (nonatomic, copy) MenuClickBlock menuClickBlock; 19 | 20 | 21 | - (instancetype)initWithFrame:(CGRect)frame 22 | superView:(UIView *)superView 23 | menusArray:(NSArray *)menusArray; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Menu/FCXPathMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // FCXPathMenu.m 3 | // Menu 4 | // 5 | // Created by 冯 传祥 on 15/9/4. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import "FCXPathMenu.h" 10 | #import "FCXPathButtonItem.h" 11 | 12 | //paht展开动画时,远点、近点、终点的展开半径 13 | static CGFloat const kFarRadius = 140.0f; 14 | static CGFloat const kNearRadius = 110.0f; 15 | static CGFloat const kEndRadius = 120.0f; 16 | 17 | 18 | @interface FCXPathMenu () 19 | 20 | @property (nonatomic, strong) UIView *pathSuperView; 21 | @property (nonatomic, strong) NSArray *menusArray; 22 | 23 | 24 | @end 25 | 26 | @implementation FCXPathMenu 27 | 28 | 29 | - (instancetype)initWithFrame:(CGRect)frame 30 | superView:(UIView *)superView 31 | menusArray:(NSArray *)menusArray { 32 | 33 | if (self = [super initWithFrame:frame]) { 34 | _mainButton = [UIButton buttonWithType:UIButtonTypeCustom]; 35 | [_mainButton setBackgroundImage:[UIImage imageNamed:@"PathMain"] forState:UIControlStateNormal]; 36 | _mainButton.frame = frame; 37 | [_mainButton addTarget:self action:@selector(mainButtonAction) forControlEvents:UIControlEventTouchUpInside]; 38 | self.pathSuperView = superView; 39 | 40 | self.menusArray = menusArray; 41 | 42 | [superView addSubview:_mainButton]; 43 | } 44 | 45 | return self; 46 | } 47 | 48 | - (void)setMenusArray:(NSArray *)menusArray { 49 | 50 | if (_menusArray != menusArray) { 51 | _menusArray = nil; 52 | _menusArray = [menusArray copy]; 53 | 54 | for (FCXPathButtonItem *item in _menusArray) { 55 | [item addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside]; 56 | item.frame = _mainButton.frame; 57 | item.startPoint = _mainButton.center; 58 | item.farPoint = CGPointMake(_mainButton.center.x + kFarRadius * cos(item.expandAngle), _mainButton.center.y - kFarRadius * sin(item.expandAngle)); 59 | item.nearPoint = CGPointMake(_mainButton.center.x + kNearRadius * cos(item.expandAngle), _mainButton.center.y - kNearRadius * sin(item.expandAngle)); 60 | item.endPoint = CGPointMake(_mainButton.center.x + kEndRadius * cos(item.expandAngle), _mainButton.center.y - kEndRadius * sin(item.expandAngle)); 61 | 62 | [self.pathSuperView addSubview:item]; 63 | } 64 | } 65 | } 66 | 67 | - (void)menuAction:(UIButton *)button { 68 | 69 | if (self.menuClickBlock) { 70 | self.menuClickBlock(button.tag); 71 | } 72 | 73 | //有动画效果 74 | [self mainButtonAction]; 75 | 76 | //点击菜单进入新界面不要动画时 77 | // [self hideMenus]; 78 | } 79 | 80 | - (void)hideMenus { 81 | 82 | self.mainButton.transform = CGAffineTransformMakeRotation(0); 83 | for (FCXPathButtonItem *item in self.menusArray) { 84 | item.center = _mainButton.center; 85 | } 86 | } 87 | 88 | -(void)mainButtonAction { 89 | 90 | if (self.isExpanding) { 91 | [self shrink]; 92 | }else{ 93 | [self expand]; 94 | } 95 | 96 | self.expanding = !self.expanding; 97 | 98 | float angle = self.isExpanding ? -M_PI_4 : 0.0f; 99 | [UIView animateWithDuration:0.3f animations:^{ 100 | _mainButton.transform = CGAffineTransformMakeRotation(angle); 101 | }]; 102 | } 103 | 104 | -(void)expand 105 | { 106 | for (FCXPathButtonItem *item in self.menusArray) { 107 | [self expand:item scale:1]; 108 | } 109 | } 110 | 111 | -(void)expand:(FCXPathButtonItem *)button scale:(CGFloat)scale { 112 | 113 | //系统原因,在7.0的系统第二次会动画会闪退 114 | if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) { 115 | CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; 116 | rotateAnimation.duration = 0.5f; 117 | rotateAnimation.values = [NSArray arrayWithObjects:[NSNumber numberWithFloat:M_PI],[NSNumber numberWithFloat:0.0f], nil]; 118 | rotateAnimation.keyTimes = [NSArray arrayWithObjects: 119 | [NSNumber numberWithFloat:.3], 120 | [NSNumber numberWithFloat:.4], nil]; 121 | 122 | CAKeyframeAnimation *zoomScale = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; 123 | zoomScale.duration = .5f; 124 | zoomScale.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(scale, scale, 1)]]; 125 | zoomScale.keyTimes = [NSArray arrayWithObjects: 126 | // [NSNumber numberWithFloat:.5], 127 | [NSNumber numberWithFloat:.3], nil]; 128 | zoomScale.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 129 | 130 | CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 131 | positionAnimation.duration = 0.5f; 132 | CGMutablePathRef path = CGPathCreateMutable(); 133 | CGPathMoveToPoint(path, NULL, button.startPoint.x, button.startPoint.y); 134 | CGPathAddLineToPoint(path, NULL, button.farPoint.x, button.farPoint.y); 135 | CGPathAddLineToPoint(path, NULL, button.nearPoint.x, button.nearPoint.y); 136 | CGPathAddLineToPoint(path, NULL, button.endPoint.x, button.endPoint.y); positionAnimation.path = path; 137 | CGPathRelease(path); 138 | 139 | CAAnimationGroup *animationgroup = [CAAnimationGroup animation]; 140 | animationgroup.animations = [NSArray arrayWithObjects:positionAnimation, zoomScale, rotateAnimation, nil]; 141 | animationgroup.duration = .5f; 142 | animationgroup.fillMode = kCAFillModeForwards; 143 | animationgroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 144 | [button.layer addAnimation:animationgroup forKey:@"Expand"]; 145 | button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y, 72 * scale, 72 * scale); 146 | button.center = button.endPoint; 147 | }else{ 148 | [UIView animateWithDuration:.3 animations:^{ 149 | button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y, 72 * scale, 72 * scale); 150 | button.center = button.endPoint; 151 | }]; 152 | } 153 | } 154 | 155 | 156 | -(void)shrink { 157 | 158 | for (FCXPathButtonItem *item in self.menusArray) { 159 | [self shrink:item scale:.8]; 160 | } 161 | } 162 | 163 | -(void)shrink:(FCXPathButtonItem *)button scale:(CGFloat)scale { 164 | 165 | //系统原因,在7.0的系统第二次会动画会闪退 166 | if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) { 167 | CAKeyframeAnimation *rotateAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"]; 168 | rotateAnimation.values = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0f],[NSNumber numberWithFloat:M_PI * 2],[NSNumber numberWithFloat:0.0f], nil]; 169 | rotateAnimation.duration = 0.5f; 170 | rotateAnimation.keyTimes = [NSArray arrayWithObjects: 171 | [NSNumber numberWithFloat:.0], 172 | [NSNumber numberWithFloat:.4], 173 | [NSNumber numberWithFloat:.5], nil]; 174 | 175 | CAKeyframeAnimation *zoomScale = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; 176 | zoomScale.duration = .5f; 177 | zoomScale.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1)], [NSValue valueWithCATransform3D:CATransform3DMakeScale(scale, scale, 1)]]; 178 | zoomScale.keyTimes = [NSArray arrayWithObjects: 179 | [NSNumber numberWithFloat:.4], 180 | [NSNumber numberWithFloat:.5], nil]; 181 | zoomScale.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; 182 | 183 | CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 184 | positionAnimation.duration = 0.5f; 185 | CGMutablePathRef path = CGPathCreateMutable(); 186 | CGPathMoveToPoint(path, NULL, button.endPoint.x, button.endPoint.y); 187 | CGPathAddLineToPoint(path, NULL, button.farPoint.x, button.farPoint.y); 188 | CGPathAddLineToPoint(path, NULL, button.startPoint.x, button.startPoint.y); 189 | positionAnimation.path = path; 190 | CGPathRelease(path); 191 | 192 | CAAnimationGroup *animationgroup = [CAAnimationGroup animation]; 193 | animationgroup.animations = [NSArray arrayWithObjects:positionAnimation, zoomScale, rotateAnimation, nil]; 194 | animationgroup.duration = .5f; 195 | animationgroup.fillMode = kCAFillModeForwards; 196 | animationgroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; 197 | [button.layer addAnimation:animationgroup forKey:@"Shrink"]; 198 | button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y, 72 * scale, 72 * scale); 199 | button.center = button.startPoint; 200 | }else{ 201 | [UIView animateWithDuration:.3 animations:^{ 202 | button.frame = CGRectMake(button.frame.origin.x, button.frame.origin.y, 72 * scale, 72 * scale); 203 | button.center = button.startPoint; 204 | }]; 205 | } 206 | } 207 | 208 | 209 | @end 210 | -------------------------------------------------------------------------------- /Menu/Images.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 | } -------------------------------------------------------------------------------- /Menu/Images.xcassets/PathEdit.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "PathEdit@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Menu/Images.xcassets/PathEdit.imageset/PathEdit@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengchuanxiang/Menu/32dd91a8fc3130c357b32c02eefc7df2f47f32d0/Menu/Images.xcassets/PathEdit.imageset/PathEdit@2x.png -------------------------------------------------------------------------------- /Menu/Images.xcassets/PathMain.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "PathMain@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Menu/Images.xcassets/PathMain.imageset/PathMain@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengchuanxiang/Menu/32dd91a8fc3130c357b32c02eefc7df2f47f32d0/Menu/Images.xcassets/PathMain.imageset/PathMain@2x.png -------------------------------------------------------------------------------- /Menu/Images.xcassets/menu.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "menu@2x.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "menu@3x.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Menu/Images.xcassets/menu.imageset/menu@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengchuanxiang/Menu/32dd91a8fc3130c357b32c02eefc7df2f47f32d0/Menu/Images.xcassets/menu.imageset/menu@2x.png -------------------------------------------------------------------------------- /Menu/Images.xcassets/menu.imageset/menu@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengchuanxiang/Menu/32dd91a8fc3130c357b32c02eefc7df2f47f32d0/Menu/Images.xcassets/menu.imageset/menu@3x.png -------------------------------------------------------------------------------- /Menu/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.wangyin..$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Menu/MenuPopover.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuPopover.h 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * 点击菜单回调block 13 | * 14 | * @param buttonIndex 点击按钮的位置 15 | */ 16 | typedef void (^MenuClickBlock)(NSInteger buttonIndex); 17 | 18 | 19 | @interface MenuPopover : UIView 20 | 21 | 22 | @property (nonatomic, copy) MenuClickBlock menuClickBlock; 23 | 24 | - (instancetype)initWithMenuFrame:(CGRect)frame menuClickBlock:(MenuClickBlock)menuClickBlock; 25 | 26 | - (void)show; 27 | 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Menu/MenuPopover.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuPopover.m 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import "MenuPopover.h" 10 | 11 | @implementation MenuPopover 12 | { 13 | UIImageView *menuImageView; 14 | } 15 | 16 | 17 | 18 | - (instancetype)initWithMenuFrame:(CGRect)frame menuClickBlock:(MenuClickBlock)menuClickBlock { 19 | 20 | if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) { 21 | 22 | self.backgroundColor = [UIColor colorWithWhite:0 alpha:.5]; 23 | self.menuClickBlock = menuClickBlock; 24 | menuImageView = [[UIImageView alloc] initWithFrame:frame]; 25 | menuImageView.image = [UIImage imageNamed:@"menu"]; 26 | menuImageView.userInteractionEnabled = YES; 27 | menuImageView.layer.anchorPoint = CGPointMake(1, 0); 28 | menuImageView.frame = frame; 29 | [self addSubview:menuImageView]; 30 | 31 | UIButton *topButton = [UIButton buttonWithType:UIButtonTypeCustom]; 32 | topButton.frame = CGRectMake(0, 8.5, 100, 43.5); 33 | topButton.tag = 0; 34 | [topButton setTitle:@"menu1" forState:UIControlStateNormal]; 35 | [topButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 36 | [topButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; 37 | [menuImageView addSubview:topButton]; 38 | 39 | UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom]; 40 | bottomButton.frame = CGRectMake(0, 8.5 + 43.5, 100, 43.5); 41 | bottomButton.tag = 1; 42 | [bottomButton setTitle:@"menu2" forState:UIControlStateNormal]; 43 | [bottomButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 44 | [bottomButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; 45 | [menuImageView addSubview:bottomButton]; 46 | 47 | UITapGestureRecognizer *tapGesgure = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)]; 48 | [self addGestureRecognizer:tapGesgure]; 49 | 50 | } 51 | return self; 52 | } 53 | 54 | 55 | - (void)buttonAction:(UIButton *)button { 56 | 57 | [self dismiss]; 58 | if (self.menuClickBlock) { 59 | self.menuClickBlock(button.tag); 60 | } 61 | 62 | } 63 | 64 | - (void)show { 65 | 66 | UIWindow* window = [UIApplication sharedApplication].keyWindow; 67 | [window addSubview:self]; 68 | 69 | __weak UIImageView *weakImageView = menuImageView; 70 | 71 | menuImageView.transform = CGAffineTransformMakeScale(0.1f, 0.1f); 72 | 73 | [UIView animateWithDuration:.15 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ 74 | 75 | weakImageView.transform = CGAffineTransformIdentity; 76 | 77 | } completion:^(BOOL finished) { 78 | 79 | }]; 80 | 81 | } 82 | 83 | - (void)dismiss { 84 | 85 | __weak __typeof(self)weakSelf = self; 86 | __weak UIImageView *weakImageView = menuImageView; 87 | 88 | [UIView animateWithDuration:.15 animations:^{ 89 | 90 | weakImageView.transform = CGAffineTransformMakeScale(0.1f, 0.1f); 91 | 92 | } completion:^(BOOL finished) { 93 | 94 | [weakSelf removeFromSuperview]; 95 | }]; 96 | 97 | } 98 | 99 | 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /Menu/MenuScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MenuScrollView.h 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | * 点击某一个菜单 13 | * 14 | * @param page 点击的页 15 | */ 16 | typedef void (^ MenuDidClickPageBlock)(NSInteger page); 17 | 18 | @interface MenuScrollView : UIScrollView 19 | 20 | 21 | @property (nonatomic, strong) UIScrollView *dataScrollView;//!< 显示数据源的scrollView 22 | @property(nonatomic, unsafe_unretained, readonly) NSInteger numberOfPages;//!< default is 0 23 | @property(nonatomic, unsafe_unretained) NSInteger currentPage;//!< default is 0. value pinned to 0..numberOfPag 24 | @property (nonatomic, copy) MenuDidClickPageBlock clickPageBlock; 25 | @property (nonatomic, unsafe_unretained) BOOL showBottomLine; 26 | @property (nonatomic, unsafe_unretained) CGFloat bottomLineIndentation;//!< default is 0 27 | @property (nonatomic, strong) UIColor *bottomLineColor; 28 | @property (nonatomic, unsafe_unretained) CGFloat bottomLineHeight;//!< default is 1 29 | @property (nonatomic, strong) UIColor *titleColorNormal; 30 | @property (nonatomic, strong) UIColor *titleColorSelected; 31 | 32 | @property (nonatomic, strong) NSArray *titleArray; 33 | 34 | 35 | 36 | - (instancetype)initWithFrame:(CGRect)frame dataScrollView:(UIScrollView *)scrollView; 37 | 38 | - (instancetype)initWithDataScrollView:(UIScrollView *)scrollView; 39 | 40 | - (void)setTitleColorNormal:(UIColor *)titleColorNormal titleColorSelected:(UIColor *)titleColorSelected; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Menu/MenuScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuScrollView.m 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import "MenuScrollView.h" 10 | 11 | @interface MenuScrollView () 12 | { 13 | CGFloat pageWidth; 14 | UIButton *lastSelectedButton;//最后一次选中的按钮 15 | NSInteger finallPage;//最后要滚动到的页(为了防止有多页时,在两个不相邻页面切换时,会调用多次setCurrentSelectedIndex方法,有多个动画效果) 16 | BOOL isDragged;//滚动是否是有手动拖拽引起的 17 | } 18 | @property (nonatomic, strong)UIView *bottomLineView; 19 | @property(nonatomic, unsafe_unretained, readwrite) NSInteger numberOfPages;//!< default is 0 20 | @property(nonatomic, unsafe_unretained) NSInteger currentSelectedIndex;//!< default is 0. 21 | 22 | @end 23 | 24 | @implementation MenuScrollView 25 | 26 | 27 | - (void)dealloc { 28 | [_dataScrollView removeObserver:self forKeyPath:@"contentOffset"]; 29 | } 30 | 31 | - (instancetype)initWithFrame:(CGRect)frame dataScrollView:(UIScrollView *)scrollView { 32 | 33 | if (self = [super initWithFrame:frame]) { 34 | self.dataScrollView = scrollView; 35 | self.bottomLineHeight = 1; 36 | self.bottomLineIndentation = 10; 37 | self.bottomLineHeight = 2; 38 | self.bottomLineColor = [UIColor redColor]; 39 | self.titleColorNormal = [UIColor blackColor]; 40 | self.titleColorSelected = [UIColor redColor]; 41 | pageWidth = frame.size.width; 42 | finallPage = 0; 43 | } 44 | 45 | return self; 46 | } 47 | 48 | - (instancetype)initWithDataScrollView:(UIScrollView *)scrollView { 49 | 50 | return [self initWithFrame:CGRectZero dataScrollView:scrollView]; 51 | } 52 | 53 | 54 | - (UIView *)bottomLineView { 55 | 56 | if (!_bottomLineView) { 57 | _bottomLineView = [[UIView alloc] init]; 58 | [self addSubview:_bottomLineView]; 59 | } 60 | return _bottomLineView; 61 | } 62 | 63 | - (void)setBottomLineColor:(UIColor *)bottomLineColor { 64 | self.bottomLineView.backgroundColor = bottomLineColor; 65 | } 66 | 67 | - (void)setBottomLineHeight:(CGFloat)bottomLineHeight { 68 | 69 | if (_bottomLineHeight != bottomLineHeight) { 70 | _bottomLineHeight = bottomLineHeight; 71 | [self changeBottomLineViewFrame:NO]; 72 | } 73 | } 74 | 75 | 76 | /** 77 | * 加这个属性是为了外部设置currentPage时有动画效果,会与现有的动画冲突 78 | * 79 | * @param currentSelectedIndex 当前选中位置 80 | */ 81 | - (void)setCurrentSelectedIndex:(NSInteger)currentSelectedIndex { 82 | 83 | if (_currentSelectedIndex != currentSelectedIndex && currentSelectedIndex == finallPage) { 84 | 85 | _currentSelectedIndex = currentSelectedIndex; 86 | _currentPage = currentSelectedIndex; 87 | 88 | UIButton *btn = (UIButton *)[self viewWithTag:currentSelectedIndex + 100]; 89 | lastSelectedButton.selected = NO; 90 | lastSelectedButton = btn; 91 | lastSelectedButton.selected = YES; 92 | 93 | if (self.clickPageBlock) { 94 | self.clickPageBlock(currentSelectedIndex); 95 | } 96 | } 97 | } 98 | 99 | - (void)setCurrentPage:(NSInteger)currentPage { 100 | 101 | if (_currentPage != currentPage) { 102 | _currentPage = currentPage; 103 | finallPage = currentPage; 104 | isDragged = NO; 105 | 106 | [self changeBottomLineViewFrame:YES]; 107 | if (self.clickPageBlock) { 108 | self.clickPageBlock(currentPage); 109 | } 110 | } 111 | } 112 | 113 | - (BOOL)shouldShowAnimationWithPage:(NSInteger)page { 114 | 115 | return YES; 116 | } 117 | 118 | - (void)setNumberOfPages:(NSInteger)numberOfPages { 119 | 120 | if (_numberOfPages != numberOfPages) { 121 | _numberOfPages = numberOfPages; 122 | 123 | pageWidth = self.frame.size.width/numberOfPages; 124 | [self changeBottomLineViewFrame:NO]; 125 | } 126 | 127 | } 128 | 129 | - (void)setTitleColorNormal:(UIColor *)titleColorNormal titleColorSelected:(UIColor *)titleColorSelected { 130 | 131 | for (UIButton *btn in self.subviews) { 132 | if ([btn isKindOfClass:[UIButton class]]) { 133 | [btn setTitleColor:titleColorNormal forState:UIControlStateNormal]; 134 | [btn setTitleColor:titleColorSelected forState:UIControlStateSelected]; 135 | [btn setTitleColor:titleColorSelected forState:UIControlStateHighlighted]; 136 | } 137 | } 138 | } 139 | 140 | - (void)setTitleColorNormal:(UIColor *)titleColorNormal { 141 | 142 | if (_titleColorNormal != titleColorNormal) { 143 | _titleColorNormal = titleColorNormal; 144 | for (UIButton *btn in self.subviews) { 145 | if ([btn isKindOfClass:[UIButton class]]) { 146 | [btn setTitleColor:titleColorNormal forState:UIControlStateNormal]; 147 | } 148 | } 149 | } 150 | } 151 | 152 | - (void)setTitleColorSelected:(UIColor *)titleColorSelected { 153 | 154 | if (_titleColorSelected != titleColorSelected) { 155 | _titleColorSelected = titleColorSelected; 156 | for (UIButton *btn in self.subviews) { 157 | if ([btn isKindOfClass:[UIButton class]]) { 158 | [btn setTitleColor:titleColorSelected forState:UIControlStateSelected]; 159 | [btn setTitleColor:titleColorSelected forState:UIControlStateHighlighted]; 160 | } 161 | } 162 | } 163 | 164 | } 165 | 166 | 167 | - (void)setTitleArray:(NSArray *)titleArray { 168 | 169 | __weak __typeof(self)weakSelf = self; 170 | self.numberOfPages = titleArray.count; 171 | [titleArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 172 | 173 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 174 | btn.tag = idx + 100; 175 | [btn setTitle:obj forState:UIControlStateNormal]; 176 | [btn setTitleColor:self.titleColorNormal forState:UIControlStateNormal]; 177 | [btn setTitleColor:self.titleColorSelected forState:UIControlStateSelected]; 178 | [btn setTitleColor:self.titleColorSelected forState:UIControlStateHighlighted]; 179 | btn.frame = CGRectMake(idx * pageWidth, 0, pageWidth, self.frame.size.height); 180 | [btn setTitle:obj forState:UIControlStateNormal]; 181 | [btn addTarget:weakSelf action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; 182 | [weakSelf addSubview:btn]; 183 | 184 | }]; 185 | } 186 | 187 | - (void)buttonAction:(UIButton *)button { 188 | 189 | if (lastSelectedButton != button) { 190 | 191 | lastSelectedButton.selected = NO; 192 | lastSelectedButton = button; 193 | lastSelectedButton.selected = YES; 194 | 195 | //为了防止有多页时,在两个不相邻页面切换时,会调用多次setCurrentSelectedIndex方法,有多个动画效果 196 | finallPage = button.tag - 100; 197 | isDragged = NO; 198 | 199 | if (self.clickPageBlock) { 200 | self.clickPageBlock(button.tag); 201 | } 202 | [self.dataScrollView scrollRectToVisible:CGRectMake((button.tag - 100) * _dataScrollView.frame.size.width, _dataScrollView.frame.origin.y, _dataScrollView.frame.size.width, _dataScrollView.frame.size.height) animated:YES]; 203 | } 204 | } 205 | 206 | - (void)changeBottomLineViewFrame:(BOOL)animated { 207 | 208 | if (animated) { 209 | 210 | __weak __typeof(self)weakSelf = self; 211 | UIView *weakView = self.bottomLineView; 212 | [UIView animateWithDuration:.15 animations:^{ 213 | weakView.frame = CGRectMake(_currentPage * pageWidth + _bottomLineIndentation, weakSelf.frame.size.height - _bottomLineHeight, pageWidth - 2 * _bottomLineIndentation, _bottomLineHeight); 214 | }]; 215 | 216 | }else { 217 | 218 | self.bottomLineView.frame = CGRectMake(_currentPage * pageWidth + _bottomLineIndentation, self.frame.size.height - _bottomLineHeight, pageWidth - 2 * _bottomLineIndentation, _bottomLineHeight); 219 | } 220 | } 221 | 222 | - (void)setDataScrollView:(UIScrollView *)dataScrollView { 223 | 224 | if (_dataScrollView != dataScrollView) { 225 | // 移除之前的监听器 226 | if (_dataScrollView) { 227 | [_dataScrollView removeObserver:self forKeyPath:@"contentOffset" context:nil]; 228 | } 229 | 230 | _dataScrollView = dataScrollView; 231 | // 监听contentOffset 232 | [_dataScrollView addObserver:self forKeyPath:@"contentOffset" options:NSKeyValueObservingOptionNew context:nil]; 233 | } 234 | } 235 | 236 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 237 | if ([keyPath isEqualToString:@"contentOffset"]) { 238 | 239 | if (_dataScrollView.isDragging) {//说明手动拖拽,不是间隔页面 240 | isDragged = YES; 241 | } 242 | 243 | NSInteger page = (_dataScrollView.contentOffset.x + [UIScreen mainScreen].bounds.size.width/2.0)/[UIScreen mainScreen].bounds.size.width; 244 | if (isDragged) { 245 | finallPage = page; 246 | } 247 | 248 | self.bottomLineView.frame = CGRectMake(_dataScrollView.contentOffset.x/_numberOfPages + _bottomLineIndentation, self.frame.size.height - _bottomLineHeight, pageWidth - 2 * _bottomLineIndentation, _bottomLineHeight); 249 | self.currentSelectedIndex = page; 250 | } 251 | } 252 | 253 | @end 254 | -------------------------------------------------------------------------------- /Menu/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Menu/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "MenuPopover.h" 11 | #import "MenuScrollView.h" 12 | #import "FCXPathMenu.h" 13 | #import "FCXPathButtonItem.h" 14 | 15 | @interface ViewController () 16 | { 17 | FCXPathMenu *pathMenu; 18 | } 19 | @property (nonatomic, strong)MenuPopover *menuView; 20 | 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | 28 | UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 29 | btn.frame = CGRectMake(self.view.frame.size.width - 80, 0, 80, 64); 30 | [btn setTitle:@"菜单" forState:UIControlStateNormal]; 31 | btn.backgroundColor = [UIColor redColor]; 32 | [btn addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside]; 33 | [self.view addSubview:btn]; 34 | 35 | 36 | UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 300)]; 37 | scrollView.contentSize = CGSizeMake(self.view.frame.size.width * 3, 300); 38 | scrollView.backgroundColor = [UIColor magentaColor]; 39 | scrollView.pagingEnabled = YES; 40 | [self.view addSubview:scrollView]; 41 | 42 | for (int i = 0; i < 3; i++) { 43 | UIView *view = [[UIView alloc] initWithFrame:CGRectMake(i * scrollView.frame.size.width, 0, scrollView.frame.size.width, scrollView.frame.size.height)]; 44 | if (i == 0) { 45 | view.backgroundColor = [UIColor greenColor]; 46 | }else if (i == 1){ 47 | view.backgroundColor = [UIColor lightGrayColor]; 48 | }else { 49 | view.backgroundColor = [UIColor yellowColor]; 50 | } 51 | [scrollView addSubview:view]; 52 | } 53 | 54 | MenuScrollView *menu = [[MenuScrollView alloc] initWithFrame:CGRectMake(0, 200 - 40, scrollView.frame.size.width, 40) dataScrollView:scrollView]; 55 | menu.backgroundColor = [UIColor purpleColor]; 56 | menu.bottomLineIndentation = 10; 57 | menu.bottomLineHeight = 2; 58 | menu.bottomLineColor = [UIColor redColor]; 59 | menu.titleArray = @[@"111111", @"2222", @"3333"]; 60 | [self.view addSubview:menu]; 61 | 62 | 63 | FCXPathButtonItem *pathItem1 = [FCXPathButtonItem buttonWithType:UIButtonTypeCustom]; 64 | pathItem1.expandAngle = M_PI_4; 65 | [pathItem1 setBackgroundImage:[UIImage imageNamed:@"PathEdit"] forState:UIControlStateNormal]; 66 | pathItem1.tag = 1; 67 | 68 | FCXPathButtonItem *pathItem2 = [FCXPathButtonItem buttonWithType:UIButtonTypeCustom]; 69 | [pathItem2 setBackgroundImage:[UIImage imageNamed:@"PathEdit"] forState:UIControlStateNormal]; 70 | pathItem2.expandAngle = M_PI_2; 71 | pathItem2.tag = 2; 72 | 73 | FCXPathButtonItem *pathItem3 = [FCXPathButtonItem buttonWithType:UIButtonTypeCustom]; 74 | [pathItem3 setBackgroundImage:[UIImage imageNamed:@"PathEdit"] forState:UIControlStateNormal]; 75 | pathItem3.tag = 3; 76 | pathItem3.expandAngle = M_PI_4 * 3; 77 | 78 | scrollView.userInteractionEnabled = YES; 79 | pathMenu = [[FCXPathMenu alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 72)/2.0, (self.view.frame.size.height - 72)/2.0, 72, 72) superView:self.view menusArray:@[pathItem1, pathItem2, pathItem3]]; 80 | pathMenu.menuClickBlock = ^(NSInteger buttonIndex){ 81 | NSLog(@"index %d", buttonIndex); 82 | }; 83 | } 84 | 85 | - (void)buttonAction { 86 | 87 | [self.menuView show]; 88 | } 89 | 90 | 91 | - (MenuPopover *)menuView { 92 | 93 | if (!_menuView) { 94 | _menuView = [[MenuPopover alloc] initWithMenuFrame:CGRectMake(self.view.frame.size.width - 95.5 - 10, 64, 95.5, 99) menuClickBlock:^(NSInteger buttonIndex) { 95 | NSLog(@"index %ld", buttonIndex); 96 | }]; 97 | } 98 | return _menuView; 99 | } 100 | 101 | - (void)didReceiveMemoryWarning { 102 | [super didReceiveMemoryWarning]; 103 | // Dispose of any resources that can be recreated. 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /Menu/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Menu 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. 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 | -------------------------------------------------------------------------------- /MenuTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.wangyin..$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /MenuTests/MenuTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // MenuTests.m 3 | // MenuTests 4 | // 5 | // Created by fcx on 15/7/31. 6 | // Copyright (c) 2015年 fcx. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface MenuTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation MenuTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Menu 2 | 写了一些项目中可能会用到的常用菜单,以后有时间会继续补充 3 | 又添加了一个path动画的菜单 4 | ![](menuDemo@3x.png) 5 | -------------------------------------------------------------------------------- /menuDemo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengchuanxiang/Menu/32dd91a8fc3130c357b32c02eefc7df2f47f32d0/menuDemo@3x.png --------------------------------------------------------------------------------