├── .gitignore ├── DOPDropDownMenuDemo ├── DOPDropDownMenuDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── DOPDropDownMenuDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── Main.storyboard │ ├── DOPDropDownMenu │ │ ├── DOPDropDownMenu.h │ │ └── DOPDropDownMenu.m │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── en.lproj │ │ └── Localizable.strings │ ├── main.m │ └── zh-Hans.lproj │ │ └── Localizable.strings └── DOPDropDownMenuDemoTests │ ├── DOPDropDownMenuDemoTests.m │ └── Info.plist ├── LICENSE ├── README.md └── images ├── sample_en.gif └── sample_zh.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 87527AB219D503A200D56994 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 87527AB119D503A200D56994 /* main.m */; }; 11 | 87527AB519D503A200D56994 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 87527AB419D503A200D56994 /* AppDelegate.m */; }; 12 | 87527AB819D503A200D56994 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 87527AB719D503A200D56994 /* ViewController.m */; }; 13 | 87527ABB19D503A200D56994 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 87527AB919D503A200D56994 /* Main.storyboard */; }; 14 | 87527ABD19D503A200D56994 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 87527ABC19D503A200D56994 /* Images.xcassets */; }; 15 | 87527ACC19D503A200D56994 /* DOPDropDownMenuDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 87527ACB19D503A200D56994 /* DOPDropDownMenuDemoTests.m */; }; 16 | 8771796E19D85D9D00BA232E /* DOPDropDownMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 8771796D19D85D9D00BA232E /* DOPDropDownMenu.m */; }; 17 | 87BFBE1E19D5176C001DB348 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 87BFBE1C19D5176C001DB348 /* Localizable.strings */; }; 18 | 87BFBE2119D51778001DB348 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 87BFBE1F19D51778001DB348 /* Localizable.strings */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 87527AC619D503A200D56994 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 87527AA419D503A200D56994 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 87527AAB19D503A200D56994; 27 | remoteInfo = DOPDropDownMenuDemo; 28 | }; 29 | /* End PBXContainerItemProxy section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 87527AAC19D503A200D56994 /* DOPDropDownMenuDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DOPDropDownMenuDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 87527AB019D503A200D56994 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 87527AB119D503A200D56994 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | 87527AB319D503A200D56994 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 36 | 87527AB419D503A200D56994 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 37 | 87527AB619D503A200D56994 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 38 | 87527AB719D503A200D56994 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 39 | 87527ABA19D503A200D56994 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | 87527ABC19D503A200D56994 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 41 | 87527AC519D503A200D56994 /* DOPDropDownMenuDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DOPDropDownMenuDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 87527ACA19D503A200D56994 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | 87527ACB19D503A200D56994 /* DOPDropDownMenuDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DOPDropDownMenuDemoTests.m; sourceTree = ""; }; 44 | 8771796C19D85D9D00BA232E /* DOPDropDownMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOPDropDownMenu.h; sourceTree = ""; }; 45 | 8771796D19D85D9D00BA232E /* DOPDropDownMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DOPDropDownMenu.m; sourceTree = ""; }; 46 | 87BFBE1D19D5176C001DB348 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 47 | 87BFBE2019D51778001DB348 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | 87527AA919D503A200D56994 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | 87527AC219D503A200D56994 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | 87527AA319D503A200D56994 = { 69 | isa = PBXGroup; 70 | children = ( 71 | 87527AAE19D503A200D56994 /* DOPDropDownMenuDemo */, 72 | 87527AC819D503A200D56994 /* DOPDropDownMenuDemoTests */, 73 | 87527AAD19D503A200D56994 /* Products */, 74 | ); 75 | sourceTree = ""; 76 | }; 77 | 87527AAD19D503A200D56994 /* Products */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 87527AAC19D503A200D56994 /* DOPDropDownMenuDemo.app */, 81 | 87527AC519D503A200D56994 /* DOPDropDownMenuDemoTests.xctest */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 87527AAE19D503A200D56994 /* DOPDropDownMenuDemo */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 8771796B19D85D9D00BA232E /* DOPDropDownMenu */, 90 | 87527AB319D503A200D56994 /* AppDelegate.h */, 91 | 87527AB419D503A200D56994 /* AppDelegate.m */, 92 | 87527AB619D503A200D56994 /* ViewController.h */, 93 | 87527AB719D503A200D56994 /* ViewController.m */, 94 | 87527AB919D503A200D56994 /* Main.storyboard */, 95 | 87527ABC19D503A200D56994 /* Images.xcassets */, 96 | 87527AAF19D503A200D56994 /* Supporting Files */, 97 | ); 98 | path = DOPDropDownMenuDemo; 99 | sourceTree = ""; 100 | }; 101 | 87527AAF19D503A200D56994 /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | 87BFBE1B19D516E5001DB348 /* en.lproj */, 105 | 87BFBE1A19D516C4001DB348 /* zh-Hans.lproj */, 106 | 87527AB019D503A200D56994 /* Info.plist */, 107 | 87527AB119D503A200D56994 /* main.m */, 108 | ); 109 | name = "Supporting Files"; 110 | sourceTree = ""; 111 | }; 112 | 87527AC819D503A200D56994 /* DOPDropDownMenuDemoTests */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 87527ACB19D503A200D56994 /* DOPDropDownMenuDemoTests.m */, 116 | 87527AC919D503A200D56994 /* Supporting Files */, 117 | ); 118 | path = DOPDropDownMenuDemoTests; 119 | sourceTree = ""; 120 | }; 121 | 87527AC919D503A200D56994 /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 87527ACA19D503A200D56994 /* Info.plist */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | 8771796B19D85D9D00BA232E /* DOPDropDownMenu */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 8771796C19D85D9D00BA232E /* DOPDropDownMenu.h */, 133 | 8771796D19D85D9D00BA232E /* DOPDropDownMenu.m */, 134 | ); 135 | path = DOPDropDownMenu; 136 | sourceTree = ""; 137 | }; 138 | 87BFBE1A19D516C4001DB348 /* zh-Hans.lproj */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 87BFBE1C19D5176C001DB348 /* Localizable.strings */, 142 | ); 143 | name = "zh-Hans.lproj"; 144 | sourceTree = ""; 145 | }; 146 | 87BFBE1B19D516E5001DB348 /* en.lproj */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | 87BFBE1F19D51778001DB348 /* Localizable.strings */, 150 | ); 151 | name = en.lproj; 152 | sourceTree = ""; 153 | }; 154 | /* End PBXGroup section */ 155 | 156 | /* Begin PBXNativeTarget section */ 157 | 87527AAB19D503A200D56994 /* DOPDropDownMenuDemo */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 87527ACF19D503A200D56994 /* Build configuration list for PBXNativeTarget "DOPDropDownMenuDemo" */; 160 | buildPhases = ( 161 | 87527AA819D503A200D56994 /* Sources */, 162 | 87527AA919D503A200D56994 /* Frameworks */, 163 | 87527AAA19D503A200D56994 /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = DOPDropDownMenuDemo; 170 | productName = DOPDropDownMenuDemo; 171 | productReference = 87527AAC19D503A200D56994 /* DOPDropDownMenuDemo.app */; 172 | productType = "com.apple.product-type.application"; 173 | }; 174 | 87527AC419D503A200D56994 /* DOPDropDownMenuDemoTests */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = 87527AD219D503A200D56994 /* Build configuration list for PBXNativeTarget "DOPDropDownMenuDemoTests" */; 177 | buildPhases = ( 178 | 87527AC119D503A200D56994 /* Sources */, 179 | 87527AC219D503A200D56994 /* Frameworks */, 180 | 87527AC319D503A200D56994 /* Resources */, 181 | ); 182 | buildRules = ( 183 | ); 184 | dependencies = ( 185 | 87527AC719D503A200D56994 /* PBXTargetDependency */, 186 | ); 187 | name = DOPDropDownMenuDemoTests; 188 | productName = DOPDropDownMenuDemoTests; 189 | productReference = 87527AC519D503A200D56994 /* DOPDropDownMenuDemoTests.xctest */; 190 | productType = "com.apple.product-type.bundle.unit-test"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | 87527AA419D503A200D56994 /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | LastUpgradeCheck = 0600; 199 | ORGANIZATIONNAME = fengweizhou; 200 | TargetAttributes = { 201 | 87527AAB19D503A200D56994 = { 202 | CreatedOnToolsVersion = 6.0.1; 203 | }; 204 | 87527AC419D503A200D56994 = { 205 | CreatedOnToolsVersion = 6.0.1; 206 | TestTargetID = 87527AAB19D503A200D56994; 207 | }; 208 | }; 209 | }; 210 | buildConfigurationList = 87527AA719D503A200D56994 /* Build configuration list for PBXProject "DOPDropDownMenuDemo" */; 211 | compatibilityVersion = "Xcode 3.2"; 212 | developmentRegion = English; 213 | hasScannedForEncodings = 0; 214 | knownRegions = ( 215 | en, 216 | Base, 217 | "zh-Hans", 218 | ); 219 | mainGroup = 87527AA319D503A200D56994; 220 | productRefGroup = 87527AAD19D503A200D56994 /* Products */; 221 | projectDirPath = ""; 222 | projectRoot = ""; 223 | targets = ( 224 | 87527AAB19D503A200D56994 /* DOPDropDownMenuDemo */, 225 | 87527AC419D503A200D56994 /* DOPDropDownMenuDemoTests */, 226 | ); 227 | }; 228 | /* End PBXProject section */ 229 | 230 | /* Begin PBXResourcesBuildPhase section */ 231 | 87527AAA19D503A200D56994 /* Resources */ = { 232 | isa = PBXResourcesBuildPhase; 233 | buildActionMask = 2147483647; 234 | files = ( 235 | 87527ABB19D503A200D56994 /* Main.storyboard in Resources */, 236 | 87BFBE2119D51778001DB348 /* Localizable.strings in Resources */, 237 | 87BFBE1E19D5176C001DB348 /* Localizable.strings in Resources */, 238 | 87527ABD19D503A200D56994 /* Images.xcassets in Resources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | 87527AC319D503A200D56994 /* Resources */ = { 243 | isa = PBXResourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | /* End PBXResourcesBuildPhase section */ 250 | 251 | /* Begin PBXSourcesBuildPhase section */ 252 | 87527AA819D503A200D56994 /* Sources */ = { 253 | isa = PBXSourcesBuildPhase; 254 | buildActionMask = 2147483647; 255 | files = ( 256 | 87527AB819D503A200D56994 /* ViewController.m in Sources */, 257 | 8771796E19D85D9D00BA232E /* DOPDropDownMenu.m in Sources */, 258 | 87527AB519D503A200D56994 /* AppDelegate.m in Sources */, 259 | 87527AB219D503A200D56994 /* main.m in Sources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | 87527AC119D503A200D56994 /* Sources */ = { 264 | isa = PBXSourcesBuildPhase; 265 | buildActionMask = 2147483647; 266 | files = ( 267 | 87527ACC19D503A200D56994 /* DOPDropDownMenuDemoTests.m in Sources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | /* End PBXSourcesBuildPhase section */ 272 | 273 | /* Begin PBXTargetDependency section */ 274 | 87527AC719D503A200D56994 /* PBXTargetDependency */ = { 275 | isa = PBXTargetDependency; 276 | target = 87527AAB19D503A200D56994 /* DOPDropDownMenuDemo */; 277 | targetProxy = 87527AC619D503A200D56994 /* PBXContainerItemProxy */; 278 | }; 279 | /* End PBXTargetDependency section */ 280 | 281 | /* Begin PBXVariantGroup section */ 282 | 87527AB919D503A200D56994 /* Main.storyboard */ = { 283 | isa = PBXVariantGroup; 284 | children = ( 285 | 87527ABA19D503A200D56994 /* Base */, 286 | ); 287 | name = Main.storyboard; 288 | sourceTree = ""; 289 | }; 290 | 87BFBE1C19D5176C001DB348 /* Localizable.strings */ = { 291 | isa = PBXVariantGroup; 292 | children = ( 293 | 87BFBE1D19D5176C001DB348 /* zh-Hans */, 294 | ); 295 | name = Localizable.strings; 296 | sourceTree = ""; 297 | }; 298 | 87BFBE1F19D51778001DB348 /* Localizable.strings */ = { 299 | isa = PBXVariantGroup; 300 | children = ( 301 | 87BFBE2019D51778001DB348 /* en */, 302 | ); 303 | name = Localizable.strings; 304 | sourceTree = ""; 305 | }; 306 | /* End PBXVariantGroup section */ 307 | 308 | /* Begin XCBuildConfiguration section */ 309 | 87527ACD19D503A200D56994 /* Debug */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | ALWAYS_SEARCH_USER_PATHS = NO; 313 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 314 | CLANG_CXX_LIBRARY = "libc++"; 315 | CLANG_ENABLE_MODULES = YES; 316 | CLANG_ENABLE_OBJC_ARC = YES; 317 | CLANG_WARN_BOOL_CONVERSION = YES; 318 | CLANG_WARN_CONSTANT_CONVERSION = YES; 319 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 320 | CLANG_WARN_EMPTY_BODY = YES; 321 | CLANG_WARN_ENUM_CONVERSION = YES; 322 | CLANG_WARN_INT_CONVERSION = YES; 323 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 324 | CLANG_WARN_UNREACHABLE_CODE = YES; 325 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 326 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 327 | COPY_PHASE_STRIP = NO; 328 | ENABLE_STRICT_OBJC_MSGSEND = YES; 329 | GCC_C_LANGUAGE_STANDARD = gnu99; 330 | GCC_DYNAMIC_NO_PIC = NO; 331 | GCC_OPTIMIZATION_LEVEL = 0; 332 | GCC_PREPROCESSOR_DEFINITIONS = ( 333 | "DEBUG=1", 334 | "$(inherited)", 335 | ); 336 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 337 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 338 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 339 | GCC_WARN_UNDECLARED_SELECTOR = YES; 340 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 341 | GCC_WARN_UNUSED_FUNCTION = YES; 342 | GCC_WARN_UNUSED_VARIABLE = YES; 343 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 344 | MTL_ENABLE_DEBUG_INFO = YES; 345 | ONLY_ACTIVE_ARCH = YES; 346 | SDKROOT = iphoneos; 347 | }; 348 | name = Debug; 349 | }; 350 | 87527ACE19D503A200D56994 /* Release */ = { 351 | isa = XCBuildConfiguration; 352 | buildSettings = { 353 | ALWAYS_SEARCH_USER_PATHS = NO; 354 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 355 | CLANG_CXX_LIBRARY = "libc++"; 356 | CLANG_ENABLE_MODULES = YES; 357 | CLANG_ENABLE_OBJC_ARC = YES; 358 | CLANG_WARN_BOOL_CONVERSION = YES; 359 | CLANG_WARN_CONSTANT_CONVERSION = YES; 360 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 361 | CLANG_WARN_EMPTY_BODY = YES; 362 | CLANG_WARN_ENUM_CONVERSION = YES; 363 | CLANG_WARN_INT_CONVERSION = YES; 364 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 365 | CLANG_WARN_UNREACHABLE_CODE = YES; 366 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 367 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 368 | COPY_PHASE_STRIP = YES; 369 | ENABLE_NS_ASSERTIONS = NO; 370 | ENABLE_STRICT_OBJC_MSGSEND = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 373 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 374 | GCC_WARN_UNDECLARED_SELECTOR = YES; 375 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 376 | GCC_WARN_UNUSED_FUNCTION = YES; 377 | GCC_WARN_UNUSED_VARIABLE = YES; 378 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 379 | MTL_ENABLE_DEBUG_INFO = NO; 380 | SDKROOT = iphoneos; 381 | VALIDATE_PRODUCT = YES; 382 | }; 383 | name = Release; 384 | }; 385 | 87527AD019D503A200D56994 /* Debug */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 389 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 390 | INFOPLIST_FILE = DOPDropDownMenuDemo/Info.plist; 391 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 392 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | }; 395 | name = Debug; 396 | }; 397 | 87527AD119D503A200D56994 /* Release */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 401 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 402 | INFOPLIST_FILE = DOPDropDownMenuDemo/Info.plist; 403 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 404 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 405 | PRODUCT_NAME = "$(TARGET_NAME)"; 406 | }; 407 | name = Release; 408 | }; 409 | 87527AD319D503A200D56994 /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | BUNDLE_LOADER = "$(TEST_HOST)"; 413 | FRAMEWORK_SEARCH_PATHS = ( 414 | "$(SDKROOT)/Developer/Library/Frameworks", 415 | "$(inherited)", 416 | ); 417 | GCC_PREPROCESSOR_DEFINITIONS = ( 418 | "DEBUG=1", 419 | "$(inherited)", 420 | ); 421 | INFOPLIST_FILE = DOPDropDownMenuDemoTests/Info.plist; 422 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DOPDropDownMenuDemo.app/DOPDropDownMenuDemo"; 425 | }; 426 | name = Debug; 427 | }; 428 | 87527AD419D503A200D56994 /* Release */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | BUNDLE_LOADER = "$(TEST_HOST)"; 432 | FRAMEWORK_SEARCH_PATHS = ( 433 | "$(SDKROOT)/Developer/Library/Frameworks", 434 | "$(inherited)", 435 | ); 436 | INFOPLIST_FILE = DOPDropDownMenuDemoTests/Info.plist; 437 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 438 | PRODUCT_NAME = "$(TARGET_NAME)"; 439 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DOPDropDownMenuDemo.app/DOPDropDownMenuDemo"; 440 | }; 441 | name = Release; 442 | }; 443 | /* End XCBuildConfiguration section */ 444 | 445 | /* Begin XCConfigurationList section */ 446 | 87527AA719D503A200D56994 /* Build configuration list for PBXProject "DOPDropDownMenuDemo" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | 87527ACD19D503A200D56994 /* Debug */, 450 | 87527ACE19D503A200D56994 /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | 87527ACF19D503A200D56994 /* Build configuration list for PBXNativeTarget "DOPDropDownMenuDemo" */ = { 456 | isa = XCConfigurationList; 457 | buildConfigurations = ( 458 | 87527AD019D503A200D56994 /* Debug */, 459 | 87527AD119D503A200D56994 /* Release */, 460 | ); 461 | defaultConfigurationIsVisible = 0; 462 | defaultConfigurationName = Release; 463 | }; 464 | 87527AD219D503A200D56994 /* Build configuration list for PBXNativeTarget "DOPDropDownMenuDemoTests" */ = { 465 | isa = XCConfigurationList; 466 | buildConfigurations = ( 467 | 87527AD319D503A200D56994 /* Debug */, 468 | 87527AD419D503A200D56994 /* Release */, 469 | ); 470 | defaultConfigurationIsVisible = 0; 471 | defaultConfigurationName = Release; 472 | }; 473 | /* End XCConfigurationList section */ 474 | }; 475 | rootObject = 87527AA419D503A200D56994 /* Project object */; 476 | } 477 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DOPDropDownMenuDemo 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. 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 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DOPDropDownMenuDemo 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. 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 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/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 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/DOPDropDownMenu/DOPDropDownMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // DOPDropDownMenu.h 3 | // DOPDropDownMenuDemo 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DOPIndexPath : NSObject 12 | 13 | @property (nonatomic, assign) NSInteger column; 14 | @property (nonatomic, assign) NSInteger row; 15 | - (instancetype)initWithColumn:(NSInteger)column row:(NSInteger)row; 16 | + (instancetype)indexPathWithCol:(NSInteger)col row:(NSInteger)row; 17 | 18 | @end 19 | 20 | #pragma mark - data source protocol 21 | @class DOPDropDownMenu; 22 | 23 | @protocol DOPDropDownMenuDataSource 24 | 25 | @required 26 | - (NSInteger)menu:(DOPDropDownMenu *)menu numberOfRowsInColumn:(NSInteger)column; 27 | - (NSString *)menu:(DOPDropDownMenu *)menu titleForRowAtIndexPath:(DOPIndexPath *)indexPath; 28 | @optional 29 | //default value is 1 30 | - (NSInteger)numberOfColumnsInMenu:(DOPDropDownMenu *)menu; 31 | 32 | @end 33 | 34 | #pragma mark - delegate 35 | @protocol DOPDropDownMenuDelegate 36 | @optional 37 | - (void)menu:(DOPDropDownMenu *)menu didSelectRowAtIndexPath:(DOPIndexPath *)indexPath; 38 | @end 39 | 40 | #pragma mark - interface 41 | @interface DOPDropDownMenu : UIView 42 | 43 | @property (nonatomic, weak) id dataSource; 44 | @property (nonatomic, weak) id delegate; 45 | 46 | @property (nonatomic, strong) UIColor *indicatorColor; 47 | @property (nonatomic, strong) UIColor *textColor; 48 | @property (nonatomic, strong) UIColor *separatorColor; 49 | /** 50 | * the width of menu will be set to screen width defaultly 51 | * 52 | * @param origin the origin of this view's frame 53 | * @param height menu's height 54 | * 55 | * @return menu 56 | */ 57 | - (instancetype)initWithOrigin:(CGPoint)origin andHeight:(CGFloat)height; 58 | - (NSString *)titleForRowAtIndexPath:(DOPIndexPath *)indexPath; 59 | 60 | //programmatically dismiss 61 | - (void)dismiss; 62 | 63 | //programmatically select row 64 | - (void)selectRow:(NSInteger)row inComponent:(NSInteger)component; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/DOPDropDownMenu/DOPDropDownMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // DOPDropDownMenu.m 3 | // DOPDropDownMenuDemo 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. All rights reserved. 7 | // 8 | 9 | #import "DOPDropDownMenu.h" 10 | 11 | @implementation DOPIndexPath 12 | - (instancetype)initWithColumn:(NSInteger)column row:(NSInteger)row { 13 | self = [super init]; 14 | if (self) { 15 | _column = column; 16 | _row = row; 17 | } 18 | return self; 19 | } 20 | 21 | + (instancetype)indexPathWithCol:(NSInteger)col row:(NSInteger)row { 22 | DOPIndexPath *indexPath = [[self alloc] initWithColumn:col row:row]; 23 | return indexPath; 24 | } 25 | @end 26 | 27 | #pragma mark - menu implementation 28 | 29 | @interface DOPDropDownMenu () 30 | @property (nonatomic, assign) NSInteger currentSelectedMenudIndex; 31 | @property (nonatomic, assign) BOOL show; 32 | @property (nonatomic, assign) NSInteger numOfMenu; 33 | @property (nonatomic, assign) CGPoint origin; 34 | @property (nonatomic, strong) UIView *backGroundView; 35 | @property (nonatomic, strong) UITableView *tableView; 36 | //data source 37 | @property (nonatomic, copy) NSArray *array; 38 | //layers array 39 | @property (nonatomic, copy) NSArray *titles; 40 | @property (nonatomic, copy) NSArray *indicators; 41 | @property (nonatomic, copy) NSArray *bgLayers; 42 | @end 43 | 44 | 45 | @implementation DOPDropDownMenu 46 | 47 | #pragma mark - getter 48 | - (UIColor *)indicatorColor { 49 | if (!_indicatorColor) { 50 | _indicatorColor = [UIColor blackColor]; 51 | } 52 | return _indicatorColor; 53 | } 54 | 55 | - (UIColor *)textColor { 56 | if (!_textColor) { 57 | _textColor = [UIColor blackColor]; 58 | } 59 | return _textColor; 60 | } 61 | 62 | - (UIColor *)separatorColor { 63 | if (!_separatorColor) { 64 | _separatorColor = [UIColor blackColor]; 65 | } 66 | return _separatorColor; 67 | } 68 | 69 | - (NSString *)titleForRowAtIndexPath:(DOPIndexPath *)indexPath { 70 | return [self.dataSource menu:self titleForRowAtIndexPath:indexPath]; 71 | } 72 | 73 | #pragma mark - setter 74 | - (void)setDataSource:(id)dataSource { 75 | _dataSource = dataSource; 76 | 77 | //configure view 78 | if ([_dataSource respondsToSelector:@selector(numberOfColumnsInMenu:)]) { 79 | _numOfMenu = [_dataSource numberOfColumnsInMenu:self]; 80 | } else { 81 | _numOfMenu = 1; 82 | } 83 | 84 | CGFloat textLayerInterval = self.frame.size.width / ( _numOfMenu * 2); 85 | CGFloat bgLayerInterval = self.frame.size.width / _numOfMenu; 86 | 87 | NSMutableArray *tempTitles = [[NSMutableArray alloc] initWithCapacity:_numOfMenu]; 88 | NSMutableArray *tempIndicators = [[NSMutableArray alloc] initWithCapacity:_numOfMenu]; 89 | NSMutableArray *tempBgLayers = [[NSMutableArray alloc] initWithCapacity:_numOfMenu]; 90 | 91 | for (int i = 0; i < _numOfMenu; i++) { 92 | //bgLayer 93 | CGPoint bgLayerPosition = CGPointMake((i+0.5)*bgLayerInterval, self.frame.size.height/2); 94 | CALayer *bgLayer = [self createBgLayerWithColor:[UIColor whiteColor] andPosition:bgLayerPosition]; 95 | [self.layer addSublayer:bgLayer]; 96 | [tempBgLayers addObject:bgLayer]; 97 | //title 98 | CGPoint titlePosition = CGPointMake( (i * 2 + 1) * textLayerInterval , self.frame.size.height / 2); 99 | NSString *titleString = [_dataSource menu:self titleForRowAtIndexPath:[DOPIndexPath indexPathWithCol:i row:0]]; 100 | CATextLayer *title = [self createTextLayerWithNSString:titleString withColor:self.textColor andPosition:titlePosition]; 101 | [self.layer addSublayer:title]; 102 | [tempTitles addObject:title]; 103 | //indicator 104 | CAShapeLayer *indicator = [self createIndicatorWithColor:self.indicatorColor andPosition:CGPointMake(titlePosition.x + title.bounds.size.width / 2 + 8, self.frame.size.height / 2)]; 105 | [self.layer addSublayer:indicator]; 106 | [tempIndicators addObject:indicator]; 107 | } 108 | _titles = [tempTitles copy]; 109 | _indicators = [tempIndicators copy]; 110 | _bgLayers = [tempBgLayers copy]; 111 | } 112 | 113 | #pragma mark - init method 114 | - (instancetype)initWithOrigin:(CGPoint)origin andHeight:(CGFloat)height { 115 | CGSize screenSize = [UIScreen mainScreen].bounds.size; 116 | self = [self initWithFrame:CGRectMake(origin.x, origin.y, screenSize.width, height)]; 117 | if (self) { 118 | _origin = origin; 119 | _currentSelectedMenudIndex = -1; 120 | _show = NO; 121 | 122 | //tableView init 123 | _tableView = [[UITableView alloc] initWithFrame:CGRectMake(origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, 0) style:UITableViewStylePlain]; 124 | _tableView.rowHeight = 38; 125 | _tableView.dataSource = self; 126 | _tableView.delegate = self; 127 | 128 | //self tapped 129 | self.backgroundColor = [UIColor whiteColor]; 130 | UIGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuTapped:)]; 131 | [self addGestureRecognizer:tapGesture]; 132 | 133 | //background init and tapped 134 | _backGroundView = [[UIView alloc] initWithFrame:CGRectMake(origin.x, origin.y, screenSize.width, screenSize.height)]; 135 | _backGroundView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.0]; 136 | _backGroundView.opaque = NO; 137 | UIGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundTapped:)]; 138 | [_backGroundView addGestureRecognizer:gesture]; 139 | 140 | //add bottom shadow 141 | UIView *bottomShadow = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height-0.5, screenSize.width, 0.5)]; 142 | bottomShadow.backgroundColor = [UIColor lightGrayColor]; 143 | [self addSubview:bottomShadow]; 144 | } 145 | return self; 146 | } 147 | 148 | #pragma mark - init support 149 | - (CALayer *)createBgLayerWithColor:(UIColor *)color andPosition:(CGPoint)position { 150 | CALayer *layer = [CALayer layer]; 151 | layer.position = position; 152 | layer.bounds = CGRectMake(0, 0, self.frame.size.width/self.numOfMenu, self.frame.size.height-1); 153 | layer.backgroundColor = color.CGColor; 154 | // NSLog(@"bglayer bounds:%@",NSStringFromCGRect(layer.bounds)); 155 | // NSLog(@"bglayer position:%@", NSStringFromCGPoint(position)); 156 | 157 | return layer; 158 | } 159 | 160 | - (CAShapeLayer *)createIndicatorWithColor:(UIColor *)color andPosition:(CGPoint)point { 161 | CAShapeLayer *layer = [CAShapeLayer new]; 162 | 163 | UIBezierPath *path = [UIBezierPath new]; 164 | [path moveToPoint:CGPointMake(0, 0)]; 165 | [path addLineToPoint:CGPointMake(8, 0)]; 166 | [path addLineToPoint:CGPointMake(4, 5)]; 167 | [path closePath]; 168 | 169 | layer.path = path.CGPath; 170 | layer.lineWidth = 1.0; 171 | layer.fillColor = color.CGColor; 172 | 173 | CGPathRef bound = CGPathCreateCopyByStrokingPath(layer.path, nil, layer.lineWidth, kCGLineCapButt, kCGLineJoinMiter, layer.miterLimit); 174 | layer.bounds = CGPathGetBoundingBox(bound); 175 | CGPathRelease(bound); 176 | 177 | layer.position = point; 178 | 179 | return layer; 180 | } 181 | 182 | - (CATextLayer *)createTextLayerWithNSString:(NSString *)string withColor:(UIColor *)color andPosition:(CGPoint)point { 183 | 184 | CGSize size = [self calculateTitleSizeWithString:string]; 185 | 186 | CATextLayer *layer = [CATextLayer new]; 187 | CGFloat sizeWidth = (size.width < (self.frame.size.width / _numOfMenu) - 25) ? size.width : self.frame.size.width / _numOfMenu - 25; 188 | layer.bounds = CGRectMake(0, 0, sizeWidth, size.height); 189 | layer.string = string; 190 | layer.fontSize = 14.0; 191 | layer.alignmentMode = kCAAlignmentCenter; 192 | layer.foregroundColor = color.CGColor; 193 | 194 | layer.contentsScale = [[UIScreen mainScreen] scale]; 195 | 196 | layer.position = point; 197 | 198 | return layer; 199 | } 200 | 201 | - (CGSize)calculateTitleSizeWithString:(NSString *)string 202 | { 203 | CGFloat fontSize = 14.0; 204 | NSDictionary *dic = @{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]}; 205 | CGSize size = [string boundingRectWithSize:CGSizeMake(280, 0) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dic context:nil].size; 206 | return size; 207 | } 208 | 209 | #pragma mark - gesture handle 210 | - (void)menuTapped:(UITapGestureRecognizer *)paramSender { 211 | CGPoint touchPoint = [paramSender locationInView:self]; 212 | //calculate index 213 | NSInteger tapIndex = touchPoint.x / (self.frame.size.width / _numOfMenu); 214 | 215 | for (int i = 0; i < _numOfMenu; i++) { 216 | if (i != tapIndex) { 217 | [self animateIndicator:_indicators[i] Forward:NO complete:^{ 218 | [self animateTitle:_titles[i] show:NO complete:^{ 219 | 220 | }]; 221 | }]; 222 | [(CALayer *)self.bgLayers[i] setBackgroundColor:[UIColor whiteColor].CGColor]; 223 | } 224 | } 225 | 226 | if (tapIndex == _currentSelectedMenudIndex && _show) { 227 | [self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView tableView:_tableView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{ 228 | _currentSelectedMenudIndex = tapIndex; 229 | _show = NO; 230 | }]; 231 | [(CALayer *)self.bgLayers[tapIndex] setBackgroundColor:[UIColor whiteColor].CGColor]; 232 | } else { 233 | _currentSelectedMenudIndex = tapIndex; 234 | [_tableView reloadData]; 235 | [self animateIdicator:_indicators[tapIndex] background:_backGroundView tableView:_tableView title:_titles[tapIndex] forward:YES complecte:^{ 236 | _show = YES; 237 | }]; 238 | [(CALayer *)self.bgLayers[tapIndex] setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0].CGColor]; 239 | } 240 | } 241 | 242 | - (void)backgroundTapped:(UITapGestureRecognizer *)paramSender 243 | { 244 | [self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView tableView:_tableView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{ 245 | _show = NO; 246 | }]; 247 | [(CALayer *)self.bgLayers[_currentSelectedMenudIndex] setBackgroundColor:[UIColor whiteColor].CGColor]; 248 | } 249 | 250 | #pragma mark - animation method 251 | - (void)animateIndicator:(CAShapeLayer *)indicator Forward:(BOOL)forward complete:(void(^)())complete { 252 | [CATransaction begin]; 253 | [CATransaction setAnimationDuration:0.25]; 254 | [CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithControlPoints:0.4 :0.0 :0.2 :1.0]]; 255 | 256 | CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"]; 257 | anim.values = forward ? @[ @0, @(M_PI) ] : @[ @(M_PI), @0 ]; 258 | 259 | if (!anim.removedOnCompletion) { 260 | [indicator addAnimation:anim forKey:anim.keyPath]; 261 | } else { 262 | [indicator addAnimation:anim forKey:anim.keyPath]; 263 | [indicator setValue:anim.values.lastObject forKeyPath:anim.keyPath]; 264 | } 265 | 266 | [CATransaction commit]; 267 | 268 | complete(); 269 | } 270 | 271 | - (void)animateBackGroundView:(UIView *)view show:(BOOL)show complete:(void(^)())complete { 272 | if (show) { 273 | [self.superview addSubview:view]; 274 | [view.superview addSubview:self]; 275 | 276 | [UIView animateWithDuration:0.2 animations:^{ 277 | view.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3]; 278 | }]; 279 | } else { 280 | [UIView animateWithDuration:0.2 animations:^{ 281 | view.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.0]; 282 | } completion:^(BOOL finished) { 283 | [view removeFromSuperview]; 284 | }]; 285 | } 286 | complete(); 287 | } 288 | 289 | - (void)animateTableView:(UITableView *)tableView show:(BOOL)show complete:(void(^)())complete { 290 | if (show) { 291 | tableView.frame = CGRectMake(self.origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, 0); 292 | [self.superview addSubview:tableView]; 293 | 294 | CGFloat tableViewHeight = ([tableView numberOfRowsInSection:0] > 5) ? (5 * tableView.rowHeight) : ([tableView numberOfRowsInSection:0] * tableView.rowHeight); 295 | 296 | [UIView animateWithDuration:0.2 animations:^{ 297 | _tableView.frame = CGRectMake(self.origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, tableViewHeight); 298 | }]; 299 | } else { 300 | [UIView animateWithDuration:0.2 animations:^{ 301 | _tableView.frame = CGRectMake(self.origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, 0); 302 | } completion:^(BOOL finished) { 303 | [tableView removeFromSuperview]; 304 | }]; 305 | } 306 | complete(); 307 | } 308 | 309 | - (void)animateTitle:(CATextLayer *)title show:(BOOL)show complete:(void(^)())complete { 310 | CGSize size = [self calculateTitleSizeWithString:title.string]; 311 | CGFloat sizeWidth = (size.width < (self.frame.size.width / _numOfMenu) - 25) ? size.width : self.frame.size.width / _numOfMenu - 25; 312 | title.bounds = CGRectMake(0, 0, sizeWidth, size.height); 313 | complete(); 314 | } 315 | 316 | - (void)animateIdicator:(CAShapeLayer *)indicator background:(UIView *)background tableView:(UITableView *)tableView title:(CATextLayer *)title forward:(BOOL)forward complecte:(void(^)())complete{ 317 | 318 | [self animateIndicator:indicator Forward:forward complete:^{ 319 | [self animateTitle:title show:forward complete:^{ 320 | [self animateBackGroundView:background show:forward complete:^{ 321 | [self animateTableView:tableView show:forward complete:^{ 322 | }]; 323 | }]; 324 | }]; 325 | }]; 326 | 327 | complete(); 328 | } 329 | 330 | #pragma mark - table datasource 331 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 332 | NSAssert(self.dataSource != nil, @"menu's dataSource shouldn't be nil"); 333 | if ([self.dataSource respondsToSelector:@selector(menu:numberOfRowsInColumn:)]) { 334 | return [self.dataSource menu:self 335 | numberOfRowsInColumn:self.currentSelectedMenudIndex]; 336 | } else { 337 | NSAssert(0 == 1, @"required method of dataSource protocol should be implemented"); 338 | return 0; 339 | } 340 | } 341 | 342 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 343 | { 344 | static NSString *identifier = @"DropDownMenuCell"; 345 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; 346 | if (!cell) { 347 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]; 348 | } 349 | NSAssert(self.dataSource != nil, @"menu's datasource shouldn't be nil"); 350 | if ([self.dataSource respondsToSelector:@selector(menu:titleForRowAtIndexPath:)]) { 351 | cell.textLabel.text = [self.dataSource menu:self titleForRowAtIndexPath:[DOPIndexPath indexPathWithCol:self.currentSelectedMenudIndex row:indexPath.row]]; 352 | } else { 353 | NSAssert(0 == 1, @"dataSource method needs to be implemented"); 354 | } 355 | cell.backgroundColor = [UIColor whiteColor]; 356 | cell.textLabel.font = [UIFont systemFontOfSize:14.0]; 357 | cell.separatorInset = UIEdgeInsetsZero; 358 | 359 | if ([cell.textLabel.text isEqualToString: [(CATextLayer *)[_titles objectAtIndex:_currentSelectedMenudIndex] string]]) { 360 | cell.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0]; 361 | } 362 | 363 | return cell; 364 | } 365 | 366 | #pragma mark - tableview delegate 367 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 368 | [self confiMenuWithSelectRow:indexPath.row]; 369 | if (self.delegate || [self.delegate respondsToSelector:@selector(menu:didSelectRowAtIndexPath:)]) { 370 | [self.delegate menu:self didSelectRowAtIndexPath:[DOPIndexPath indexPathWithCol:self.currentSelectedMenudIndex row:indexPath.row]]; 371 | } 372 | } 373 | 374 | - (void)confiMenuWithSelectRow:(NSInteger)row { 375 | CATextLayer *title = (CATextLayer *)_titles[_currentSelectedMenudIndex]; 376 | title.string = [self.dataSource menu:self titleForRowAtIndexPath:[DOPIndexPath indexPathWithCol:self.currentSelectedMenudIndex row:row]]; 377 | 378 | [self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView tableView:_tableView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{ 379 | _show = NO; 380 | }]; 381 | [(CALayer *)self.bgLayers[_currentSelectedMenudIndex] setBackgroundColor:[UIColor whiteColor].CGColor]; 382 | 383 | CAShapeLayer *indicator = (CAShapeLayer *)_indicators[_currentSelectedMenudIndex]; 384 | indicator.position = CGPointMake(title.position.x + title.frame.size.width / 2 + 8, indicator.position.y); 385 | } 386 | 387 | - (void)dismiss { 388 | [self backgroundTapped:nil]; 389 | } 390 | 391 | - (void)selectRow:(NSInteger)row inComponent:(NSInteger)component { 392 | _currentSelectedMenudIndex = component; 393 | [self confiMenuWithSelectRow: row]; 394 | } 395 | 396 | @end 397 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/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 | } -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "minimum-system-version" : "7.0", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "orientation" : "portrait", 11 | "idiom" : "iphone", 12 | "minimum-system-version" : "7.0", 13 | "subtype" : "retina4", 14 | "scale" : "2x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | fengweizhou.$(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 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DOPDropDownMenuDemo 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DOPDropDownMenuDemo 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DOPDropDownMenu.h" 11 | 12 | @interface ViewController () 13 | @property (nonatomic, copy) NSArray *citys; 14 | @property (nonatomic, copy) NSArray *ages; 15 | @property (nonatomic, copy) NSArray *genders; 16 | @property (nonatomic, copy) NSArray *originalArray; 17 | @property (nonatomic, copy) NSArray *results; 18 | 19 | @property (nonatomic, strong) UITableView *tableView; 20 | @property (nonatomic, strong) DOPDropDownMenu *menu; 21 | @end 22 | 23 | @implementation ViewController 24 | 25 | - (void)viewDidLoad { 26 | [super viewDidLoad]; 27 | self.navigationItem.title = NSLocalizedString(@"navbar_title", @"the navigation bar title"); 28 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"dismiss" style:UIBarButtonItemStylePlain target:self action:@selector(dismiss:)]; 29 | self.citys = @[NSLocalizedString(@"city1", @"city1"), 30 | NSLocalizedString(@"city2", @"city2"), 31 | NSLocalizedString(@"city3", @"city3")]; 32 | self.ages = @[NSLocalizedString(@"age", @"age"), @"20", @"30"]; 33 | self.genders = @[NSLocalizedString(@"gender1", @"gender1"), 34 | NSLocalizedString(@"gender2", @"gender2"), 35 | NSLocalizedString(@"gender3", @"gender3")]; 36 | self.originalArray = @[[NSString stringWithFormat:@"%@_%@_%@",self.citys[1],self.ages[1],self.genders[1]], 37 | [NSString stringWithFormat:@"%@_%@_%@",self.citys[1],self.ages[1],self.genders[2]], 38 | [NSString stringWithFormat:@"%@_%@_%@",self.citys[1],self.ages[2],self.genders[1]], 39 | [NSString stringWithFormat:@"%@_%@_%@",self.citys[1],self.ages[2],self.genders[2]], 40 | [NSString stringWithFormat:@"%@_%@_%@",self.citys[2],self.ages[1],self.genders[1]], 41 | [NSString stringWithFormat:@"%@_%@_%@",self.citys[2],self.ages[1],self.genders[2]], 42 | [NSString stringWithFormat:@"%@_%@_%@",self.citys[2],self.ages[2],self.genders[1]], 43 | [NSString stringWithFormat:@"%@_%@_%@",self.citys[2],self.ages[2],self.genders[2]]]; 44 | self.results = self.originalArray; 45 | 46 | DOPDropDownMenu *menu = [[DOPDropDownMenu alloc] initWithOrigin:CGPointMake(0, 64) andHeight:40]; 47 | menu.dataSource = self; 48 | menu.delegate = self; 49 | [self.view addSubview:menu]; 50 | self.menu = menu; 51 | 52 | self.tableView = ({ 53 | CGSize screenSize = [UIScreen mainScreen].bounds.size; 54 | UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 104, screenSize.width, screenSize.height - 104)]; 55 | tableView.dataSource = self; 56 | [self.view addSubview:tableView]; 57 | tableView; 58 | }); 59 | } 60 | 61 | - (void)didReceiveMemoryWarning { 62 | [super didReceiveMemoryWarning]; 63 | // Dispose of any resources that can be recreated. 64 | } 65 | 66 | - (void)dismiss:(UIBarButtonItem *)sender { 67 | [self.menu dismiss]; 68 | } 69 | 70 | - (NSInteger)numberOfColumnsInMenu:(DOPDropDownMenu *)menu { 71 | return 3; 72 | } 73 | 74 | - (NSInteger)menu:(DOPDropDownMenu *)menu numberOfRowsInColumn:(NSInteger)column { 75 | return 3; 76 | } 77 | 78 | - (NSString *)menu:(DOPDropDownMenu *)menu titleForRowAtIndexPath:(DOPIndexPath *)indexPath { 79 | switch (indexPath.column) { 80 | case 0: return self.citys[indexPath.row]; 81 | break; 82 | case 1: return self.genders[indexPath.row]; 83 | break; 84 | case 2: return self.ages[indexPath.row]; 85 | break; 86 | default: 87 | return nil; 88 | break; 89 | } 90 | } 91 | 92 | - (void)menu:(DOPDropDownMenu *)menu didSelectRowAtIndexPath:(DOPIndexPath *)indexPath { 93 | NSLog(@"column:%li row:%li", (long)indexPath.column, (long)indexPath.row); 94 | NSLog(@"%@",[menu titleForRowAtIndexPath:indexPath]); 95 | NSString *title = [menu titleForRowAtIndexPath:indexPath]; 96 | 97 | static NSString *prediStr1 = @"SELF LIKE '*'", 98 | *prediStr2 = @"SELF LIKE '*'", 99 | *prediStr3 = @"SELF LIKE '*'"; 100 | switch (indexPath.column) { 101 | case 0:{ 102 | if (indexPath.row == 0) { 103 | prediStr1 = @"SELF LIKE '*'"; 104 | } else { 105 | prediStr1 = [NSString stringWithFormat:@"SELF CONTAINS '%@'", title]; 106 | } 107 | } 108 | break; 109 | case 1:{ 110 | if (indexPath.row == 0) { 111 | prediStr2 = @"SELF LIKE '*'"; 112 | } else { 113 | prediStr2 = [NSString stringWithFormat:@"SELF CONTAINS '%@'", title]; 114 | } 115 | } 116 | break; 117 | case 2:{ 118 | if (indexPath.row == 0) { 119 | prediStr3 = @"SELF LIKE '*'"; 120 | } else { 121 | prediStr3 = [NSString stringWithFormat:@"SELF CONTAINS '%@'", title]; 122 | } 123 | } 124 | 125 | default: 126 | break; 127 | } 128 | NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"%@ AND %@ AND %@",prediStr1,prediStr2,prediStr3]]; 129 | 130 | self.results = [self.originalArray filteredArrayUsingPredicate:predicate]; 131 | [self.tableView reloadData]; 132 | } 133 | 134 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 135 | return self.results.count; 136 | } 137 | 138 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 139 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 140 | cell.textLabel.text = self.results[indexPath.row]; 141 | return cell; 142 | } 143 | 144 | @end 145 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopcn/DOPDropDownMenu/a07bd13022e3b07b9ec216881de194ad048b024e/DOPDropDownMenuDemo/DOPDropDownMenuDemo/en.lproj/Localizable.strings -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DOPDropDownMenuDemo 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. 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 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemo/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopcn/DOPDropDownMenu/a07bd13022e3b07b9ec216881de194ad048b024e/DOPDropDownMenuDemo/DOPDropDownMenuDemo/zh-Hans.lproj/Localizable.strings -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemoTests/DOPDropDownMenuDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DOPDropDownMenuDemoTests.m 3 | // DOPDropDownMenuDemoTests 4 | // 5 | // Created by weizhou on 9/26/14. 6 | // Copyright (c) 2014 fengweizhou. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface DOPDropDownMenuDemoTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation DOPDropDownMenuDemoTests 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 | -------------------------------------------------------------------------------- /DOPDropDownMenuDemo/DOPDropDownMenuDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | fengweizhou.$(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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Weizhou 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DOPDropDownMenu 2 | =============== 3 | 4 | Drop down menu like we see on website for iPhone.. 5 | 6 | ![image](https://github.com/dopcn/DOPDropDownMenu/blob/master/images/sample_en.gif) 7 | 8 | works the same as `UITableView` with a `dataSource` and a `delegate` 9 | 10 | ```objc 11 | #pragma mark - data source protocol 12 | @protocol DOPDropDownMenuDataSource 13 | @required 14 | - (NSInteger)menu:(DOPDropDownMenu *)menu numberOfRowsInColumn:(NSInteger)column; 15 | - (NSString *)menu:(DOPDropDownMenu *)menu titleForRowAtIndexPath:(DOPIndexPath *)indexPath; 16 | @optional 17 | //default value is 1 18 | - (NSInteger)numberOfColumnsInMenu:(DOPDropDownMenu *)menu; 19 | @end 20 | 21 | #pragma mark - delegate 22 | @protocol DOPDropDownMenuDelegate 23 | @optional 24 | - (void)menu:(DOPDropDownMenu *)menu didSelectRowAtIndexPath:(DOPIndexPath *)indexPath; 25 | @end 26 | ``` 27 | 28 | The menu will set it's width equal to screen width defaultly 29 | 30 | ```objc 31 | /** 32 | * the width of menu will be set to screen width defaultly 33 | * 34 | * @param origin the origin of this view's frame 35 | * @param height menu's height 36 | * 37 | * @return menu 38 | */ 39 | - (instancetype)initWithOrigin:(CGPoint)origin andHeight:(CGFloat)height; 40 | ``` 41 | 42 | ### DOPDropDownMenu-Enhanced 43 | 44 | There is a new DOPDropDownMenu-Enhanced, https://github.com/12207480/DOPDropDownMenu-Enhanced 45 | 46 | on the basis of this, add double tableView , to optimize the code, improves stability , 47 | 48 | this project is inspired by [MXPullDownMenu](https://github.com/xxxxxtongxue/MXPullDownMenu) 49 | 50 | ### Swift Version Used 51 | 52 | Swift version of DOPDropDownMenu : https://github.com/javalnanda/JNDropDownMenu 53 | -------------------------------------------------------------------------------- /images/sample_en.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopcn/DOPDropDownMenu/a07bd13022e3b07b9ec216881de194ad048b024e/images/sample_en.gif -------------------------------------------------------------------------------- /images/sample_zh.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dopcn/DOPDropDownMenu/a07bd13022e3b07b9ec216881de194ad048b024e/images/sample_zh.gif --------------------------------------------------------------------------------