├── .gitignore ├── CCDropDownMenu.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── CCDropDownMenus.xcscheme ├── CCDropDownMenu ├── CCDropDownMenu.h ├── CCDropDownMenu.m ├── CCDropDownMenuCell.h ├── CCDropDownMenuCell.m ├── CCDropDownMenus.h ├── GaiDropDownMenu.h ├── GaiDropDownMenu.m ├── Info.plist ├── ManaDropDownMenu.h ├── ManaDropDownMenu.m ├── Rect.h ├── SyuDropDownMenu.h ├── SyuDropDownMenu.m └── arrow.png ├── CCDropDownMenuSample ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── cloud.png ├── main.m ├── rain.png ├── snow.png └── sun.png ├── CCDropDownMenus.podspec ├── Captures ├── capture1.gif ├── capture2.gif └── capture3.gif ├── Licence └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Xcode 3 | # 4 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 5 | 6 | ## Build generated 7 | build/ 8 | DerivedData/ 9 | 10 | ## Various settings 11 | *.pbxuser 12 | !default.pbxuser 13 | *.mode1v3 14 | !default.mode1v3 15 | *.mode2v3 16 | !default.mode2v3 17 | *.perspectivev3 18 | !default.perspectivev3 19 | xcuserdata/ 20 | 21 | ## Other 22 | *.moved-aside 23 | *.xcuserstate 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/' 61 | -------------------------------------------------------------------------------- /CCDropDownMenu.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B628890F1D2FB456009E35E3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B628890E1D2FB456009E35E3 /* main.m */; }; 11 | B62889121D2FB456009E35E3 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B62889111D2FB456009E35E3 /* AppDelegate.m */; }; 12 | B62889151D2FB456009E35E3 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B62889141D2FB456009E35E3 /* ViewController.m */; }; 13 | B62889181D2FB456009E35E3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B62889161D2FB456009E35E3 /* Main.storyboard */; }; 14 | B628891A1D2FB456009E35E3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B62889191D2FB456009E35E3 /* Assets.xcassets */; }; 15 | B628891D1D2FB456009E35E3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B628891B1D2FB456009E35E3 /* LaunchScreen.storyboard */; }; 16 | B628892A1D2FCD02009E35E3 /* arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = B62889291D2FCD02009E35E3 /* arrow.png */; }; 17 | B62889331D307101009E35E3 /* cloud.png in Resources */ = {isa = PBXBuildFile; fileRef = B628892F1D307101009E35E3 /* cloud.png */; }; 18 | B62889341D307101009E35E3 /* rain.png in Resources */ = {isa = PBXBuildFile; fileRef = B62889301D307101009E35E3 /* rain.png */; }; 19 | B62889351D307101009E35E3 /* snow.png in Resources */ = {isa = PBXBuildFile; fileRef = B62889311D307101009E35E3 /* snow.png */; }; 20 | B62889361D307101009E35E3 /* sun.png in Resources */ = {isa = PBXBuildFile; fileRef = B62889321D307101009E35E3 /* sun.png */; }; 21 | B6488C531D34C00400D6CC32 /* CCDropDownMenus.h in Headers */ = {isa = PBXBuildFile; fileRef = B6488C521D34C00400D6CC32 /* CCDropDownMenus.h */; settings = {ATTRIBUTES = (Public, ); }; }; 22 | B6488C571D34C00400D6CC32 /* CCDropDownMenus.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B6488C501D34C00400D6CC32 /* CCDropDownMenus.framework */; }; 23 | B6488C581D34C00400D6CC32 /* CCDropDownMenus.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = B6488C501D34C00400D6CC32 /* CCDropDownMenus.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 24 | B6488C5D1D34C0DE00D6CC32 /* arrow.png in Resources */ = {isa = PBXBuildFile; fileRef = B62889291D2FCD02009E35E3 /* arrow.png */; }; 25 | B6488C5E1D34C0FA00D6CC32 /* CCDropDownMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = B62889271D2FBC50009E35E3 /* CCDropDownMenu.m */; }; 26 | B6488C5F1D34C0FA00D6CC32 /* CCDropDownMenuCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B628892C1D2FD892009E35E3 /* CCDropDownMenuCell.m */; }; 27 | B6488C601D34C0FA00D6CC32 /* ManaDropDownMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = B62889381D30785C009E35E3 /* ManaDropDownMenu.m */; }; 28 | B6488C611D34C0FA00D6CC32 /* GaiDropDownMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = B6488C371D34809600D6CC32 /* GaiDropDownMenu.m */; }; 29 | B6488C621D34C0FA00D6CC32 /* SyuDropDownMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = B68B98E81D3369EB001CA29F /* SyuDropDownMenu.m */; }; 30 | B6488C631D34C11200D6CC32 /* ManaDropDownMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = B62889371D30785C009E35E3 /* ManaDropDownMenu.h */; settings = {ATTRIBUTES = (Public, ); }; }; 31 | B6488C641D34C11400D6CC32 /* GaiDropDownMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = B6488C361D34809600D6CC32 /* GaiDropDownMenu.h */; settings = {ATTRIBUTES = (Public, ); }; }; 32 | B6488C651D34C11700D6CC32 /* SyuDropDownMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = B68B98E71D3369EB001CA29F /* SyuDropDownMenu.h */; settings = {ATTRIBUTES = (Public, ); }; }; 33 | B6488C671D34C13B00D6CC32 /* CCDropDownMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = B62889261D2FBC50009E35E3 /* CCDropDownMenu.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34 | B6488C681D34C14000D6CC32 /* Rect.h in Headers */ = {isa = PBXBuildFile; fileRef = B628893D1D3097E0009E35E3 /* Rect.h */; settings = {ATTRIBUTES = (Public, ); }; }; 35 | B6488C691D34C14800D6CC32 /* CCDropDownMenuCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B628892B1D2FD892009E35E3 /* CCDropDownMenuCell.h */; settings = {ATTRIBUTES = (Public, ); }; }; 36 | /* End PBXBuildFile section */ 37 | 38 | /* Begin PBXContainerItemProxy section */ 39 | B6488C551D34C00400D6CC32 /* PBXContainerItemProxy */ = { 40 | isa = PBXContainerItemProxy; 41 | containerPortal = B62889021D2FB456009E35E3 /* Project object */; 42 | proxyType = 1; 43 | remoteGlobalIDString = B6488C4F1D34C00400D6CC32; 44 | remoteInfo = CCDropDownMenus; 45 | }; 46 | /* End PBXContainerItemProxy section */ 47 | 48 | /* Begin PBXCopyFilesBuildPhase section */ 49 | B6488C5C1D34C00500D6CC32 /* Embed Frameworks */ = { 50 | isa = PBXCopyFilesBuildPhase; 51 | buildActionMask = 2147483647; 52 | dstPath = ""; 53 | dstSubfolderSpec = 10; 54 | files = ( 55 | B6488C581D34C00400D6CC32 /* CCDropDownMenus.framework in Embed Frameworks */, 56 | ); 57 | name = "Embed Frameworks"; 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXCopyFilesBuildPhase section */ 61 | 62 | /* Begin PBXFileReference section */ 63 | B628890A1D2FB456009E35E3 /* CCDropDownMenuSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CCDropDownMenuSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | B628890E1D2FB456009E35E3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 65 | B62889101D2FB456009E35E3 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 66 | B62889111D2FB456009E35E3 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 67 | B62889131D2FB456009E35E3 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 68 | B62889141D2FB456009E35E3 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 69 | B62889171D2FB456009E35E3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 70 | B62889191D2FB456009E35E3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 71 | B628891C1D2FB456009E35E3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 72 | B628891E1D2FB456009E35E3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73 | B62889261D2FBC50009E35E3 /* CCDropDownMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDropDownMenu.h; sourceTree = ""; }; 74 | B62889271D2FBC50009E35E3 /* CCDropDownMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCDropDownMenu.m; sourceTree = ""; }; 75 | B62889291D2FCD02009E35E3 /* arrow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = arrow.png; sourceTree = ""; }; 76 | B628892B1D2FD892009E35E3 /* CCDropDownMenuCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCDropDownMenuCell.h; sourceTree = ""; }; 77 | B628892C1D2FD892009E35E3 /* CCDropDownMenuCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCDropDownMenuCell.m; sourceTree = ""; }; 78 | B628892F1D307101009E35E3 /* cloud.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = cloud.png; sourceTree = ""; }; 79 | B62889301D307101009E35E3 /* rain.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rain.png; sourceTree = ""; }; 80 | B62889311D307101009E35E3 /* snow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = snow.png; sourceTree = ""; }; 81 | B62889321D307101009E35E3 /* sun.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = sun.png; sourceTree = ""; }; 82 | B62889371D30785C009E35E3 /* ManaDropDownMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ManaDropDownMenu.h; sourceTree = ""; }; 83 | B62889381D30785C009E35E3 /* ManaDropDownMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ManaDropDownMenu.m; sourceTree = ""; }; 84 | B628893D1D3097E0009E35E3 /* Rect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Rect.h; sourceTree = ""; }; 85 | B6488C361D34809600D6CC32 /* GaiDropDownMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GaiDropDownMenu.h; sourceTree = ""; }; 86 | B6488C371D34809600D6CC32 /* GaiDropDownMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GaiDropDownMenu.m; sourceTree = ""; }; 87 | B6488C501D34C00400D6CC32 /* CCDropDownMenus.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CCDropDownMenus.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 88 | B6488C521D34C00400D6CC32 /* CCDropDownMenus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CCDropDownMenus.h; path = CCDropDownMenu/CCDropDownMenus.h; sourceTree = SOURCE_ROOT; }; 89 | B6488C541D34C00400D6CC32 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = CCDropDownMenu/Info.plist; sourceTree = SOURCE_ROOT; }; 90 | B68B98E71D3369EB001CA29F /* SyuDropDownMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SyuDropDownMenu.h; sourceTree = ""; }; 91 | B68B98E81D3369EB001CA29F /* SyuDropDownMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SyuDropDownMenu.m; sourceTree = ""; }; 92 | /* End PBXFileReference section */ 93 | 94 | /* Begin PBXFrameworksBuildPhase section */ 95 | B62889071D2FB456009E35E3 /* Frameworks */ = { 96 | isa = PBXFrameworksBuildPhase; 97 | buildActionMask = 2147483647; 98 | files = ( 99 | B6488C571D34C00400D6CC32 /* CCDropDownMenus.framework in Frameworks */, 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | B6488C4C1D34C00400D6CC32 /* Frameworks */ = { 104 | isa = PBXFrameworksBuildPhase; 105 | buildActionMask = 2147483647; 106 | files = ( 107 | ); 108 | runOnlyForDeploymentPostprocessing = 0; 109 | }; 110 | /* End PBXFrameworksBuildPhase section */ 111 | 112 | /* Begin PBXGroup section */ 113 | B62889011D2FB456009E35E3 = { 114 | isa = PBXGroup; 115 | children = ( 116 | B628890C1D2FB456009E35E3 /* CCDropDownMenuSample */, 117 | B62889241D2FB4DB009E35E3 /* CCDropDownMenus */, 118 | B628890B1D2FB456009E35E3 /* Products */, 119 | ); 120 | sourceTree = ""; 121 | }; 122 | B628890B1D2FB456009E35E3 /* Products */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | B628890A1D2FB456009E35E3 /* CCDropDownMenuSample.app */, 126 | B6488C501D34C00400D6CC32 /* CCDropDownMenus.framework */, 127 | ); 128 | name = Products; 129 | sourceTree = ""; 130 | }; 131 | B628890C1D2FB456009E35E3 /* CCDropDownMenuSample */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | B62889101D2FB456009E35E3 /* AppDelegate.h */, 135 | B62889111D2FB456009E35E3 /* AppDelegate.m */, 136 | B62889131D2FB456009E35E3 /* ViewController.h */, 137 | B62889141D2FB456009E35E3 /* ViewController.m */, 138 | B628892E1D3070EA009E35E3 /* Resources */, 139 | B62889161D2FB456009E35E3 /* Main.storyboard */, 140 | B62889191D2FB456009E35E3 /* Assets.xcassets */, 141 | B628891B1D2FB456009E35E3 /* LaunchScreen.storyboard */, 142 | B628891E1D2FB456009E35E3 /* Info.plist */, 143 | B628890D1D2FB456009E35E3 /* Supporting Files */, 144 | ); 145 | path = CCDropDownMenuSample; 146 | sourceTree = ""; 147 | }; 148 | B628890D1D2FB456009E35E3 /* Supporting Files */ = { 149 | isa = PBXGroup; 150 | children = ( 151 | B628890E1D2FB456009E35E3 /* main.m */, 152 | ); 153 | name = "Supporting Files"; 154 | sourceTree = ""; 155 | }; 156 | B62889241D2FB4DB009E35E3 /* CCDropDownMenus */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | B6488C541D34C00400D6CC32 /* Info.plist */, 160 | B628893D1D3097E0009E35E3 /* Rect.h */, 161 | B6488C521D34C00400D6CC32 /* CCDropDownMenus.h */, 162 | B62889261D2FBC50009E35E3 /* CCDropDownMenu.h */, 163 | B62889271D2FBC50009E35E3 /* CCDropDownMenu.m */, 164 | B628892B1D2FD892009E35E3 /* CCDropDownMenuCell.h */, 165 | B628892C1D2FD892009E35E3 /* CCDropDownMenuCell.m */, 166 | B628893A1D307864009E35E3 /* ManaDropDownMenu */, 167 | B6488C351D34800400D6CC32 /* GaiDropDownMenu */, 168 | B628893B1D3078C7009E35E3 /* SyuDropDownMenu */, 169 | B628893C1D3078FE009E35E3 /* Resuorces */, 170 | ); 171 | name = CCDropDownMenus; 172 | path = CCDropDownMenu; 173 | sourceTree = ""; 174 | }; 175 | B628892E1D3070EA009E35E3 /* Resources */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | B628892F1D307101009E35E3 /* cloud.png */, 179 | B62889301D307101009E35E3 /* rain.png */, 180 | B62889311D307101009E35E3 /* snow.png */, 181 | B62889321D307101009E35E3 /* sun.png */, 182 | ); 183 | name = Resources; 184 | sourceTree = ""; 185 | }; 186 | B628893A1D307864009E35E3 /* ManaDropDownMenu */ = { 187 | isa = PBXGroup; 188 | children = ( 189 | B62889371D30785C009E35E3 /* ManaDropDownMenu.h */, 190 | B62889381D30785C009E35E3 /* ManaDropDownMenu.m */, 191 | ); 192 | name = ManaDropDownMenu; 193 | sourceTree = ""; 194 | }; 195 | B628893B1D3078C7009E35E3 /* SyuDropDownMenu */ = { 196 | isa = PBXGroup; 197 | children = ( 198 | B68B98E71D3369EB001CA29F /* SyuDropDownMenu.h */, 199 | B68B98E81D3369EB001CA29F /* SyuDropDownMenu.m */, 200 | ); 201 | name = SyuDropDownMenu; 202 | sourceTree = ""; 203 | }; 204 | B628893C1D3078FE009E35E3 /* Resuorces */ = { 205 | isa = PBXGroup; 206 | children = ( 207 | B62889291D2FCD02009E35E3 /* arrow.png */, 208 | ); 209 | name = Resuorces; 210 | sourceTree = ""; 211 | }; 212 | B6488C351D34800400D6CC32 /* GaiDropDownMenu */ = { 213 | isa = PBXGroup; 214 | children = ( 215 | B6488C361D34809600D6CC32 /* GaiDropDownMenu.h */, 216 | B6488C371D34809600D6CC32 /* GaiDropDownMenu.m */, 217 | ); 218 | name = GaiDropDownMenu; 219 | sourceTree = ""; 220 | }; 221 | /* End PBXGroup section */ 222 | 223 | /* Begin PBXHeadersBuildPhase section */ 224 | B6488C4D1D34C00400D6CC32 /* Headers */ = { 225 | isa = PBXHeadersBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | B6488C531D34C00400D6CC32 /* CCDropDownMenus.h in Headers */, 229 | B6488C671D34C13B00D6CC32 /* CCDropDownMenu.h in Headers */, 230 | B6488C691D34C14800D6CC32 /* CCDropDownMenuCell.h in Headers */, 231 | B6488C631D34C11200D6CC32 /* ManaDropDownMenu.h in Headers */, 232 | B6488C641D34C11400D6CC32 /* GaiDropDownMenu.h in Headers */, 233 | B6488C651D34C11700D6CC32 /* SyuDropDownMenu.h in Headers */, 234 | B6488C681D34C14000D6CC32 /* Rect.h in Headers */, 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | }; 238 | /* End PBXHeadersBuildPhase section */ 239 | 240 | /* Begin PBXNativeTarget section */ 241 | B62889091D2FB456009E35E3 /* CCDropDownMenuSample */ = { 242 | isa = PBXNativeTarget; 243 | buildConfigurationList = B62889211D2FB456009E35E3 /* Build configuration list for PBXNativeTarget "CCDropDownMenuSample" */; 244 | buildPhases = ( 245 | B62889061D2FB456009E35E3 /* Sources */, 246 | B62889071D2FB456009E35E3 /* Frameworks */, 247 | B62889081D2FB456009E35E3 /* Resources */, 248 | B6488C5C1D34C00500D6CC32 /* Embed Frameworks */, 249 | ); 250 | buildRules = ( 251 | ); 252 | dependencies = ( 253 | B6488C561D34C00400D6CC32 /* PBXTargetDependency */, 254 | ); 255 | name = CCDropDownMenuSample; 256 | productName = CCDropDownMenu; 257 | productReference = B628890A1D2FB456009E35E3 /* CCDropDownMenuSample.app */; 258 | productType = "com.apple.product-type.application"; 259 | }; 260 | B6488C4F1D34C00400D6CC32 /* CCDropDownMenus */ = { 261 | isa = PBXNativeTarget; 262 | buildConfigurationList = B6488C5B1D34C00500D6CC32 /* Build configuration list for PBXNativeTarget "CCDropDownMenus" */; 263 | buildPhases = ( 264 | B6488C4B1D34C00400D6CC32 /* Sources */, 265 | B6488C4C1D34C00400D6CC32 /* Frameworks */, 266 | B6488C4D1D34C00400D6CC32 /* Headers */, 267 | B6488C4E1D34C00400D6CC32 /* Resources */, 268 | ); 269 | buildRules = ( 270 | ); 271 | dependencies = ( 272 | ); 273 | name = CCDropDownMenus; 274 | productName = CCDropDownMenus; 275 | productReference = B6488C501D34C00400D6CC32 /* CCDropDownMenus.framework */; 276 | productType = "com.apple.product-type.framework"; 277 | }; 278 | /* End PBXNativeTarget section */ 279 | 280 | /* Begin PBXProject section */ 281 | B62889021D2FB456009E35E3 /* Project object */ = { 282 | isa = PBXProject; 283 | attributes = { 284 | LastUpgradeCheck = 0730; 285 | ORGANIZATIONNAME = Cokile; 286 | TargetAttributes = { 287 | B62889091D2FB456009E35E3 = { 288 | CreatedOnToolsVersion = 7.3.1; 289 | DevelopmentTeam = 5B73F3N5VZ; 290 | DevelopmentTeamName = "Cokile Kelvin (Personal Team)"; 291 | }; 292 | B6488C4F1D34C00400D6CC32 = { 293 | CreatedOnToolsVersion = 7.3.1; 294 | DevelopmentTeam = 5B73F3N5VZ; 295 | }; 296 | }; 297 | }; 298 | buildConfigurationList = B62889051D2FB456009E35E3 /* Build configuration list for PBXProject "CCDropDownMenu" */; 299 | compatibilityVersion = "Xcode 3.2"; 300 | developmentRegion = English; 301 | hasScannedForEncodings = 0; 302 | knownRegions = ( 303 | en, 304 | Base, 305 | ); 306 | mainGroup = B62889011D2FB456009E35E3; 307 | productRefGroup = B628890B1D2FB456009E35E3 /* Products */; 308 | projectDirPath = ""; 309 | projectRoot = ""; 310 | targets = ( 311 | B62889091D2FB456009E35E3 /* CCDropDownMenuSample */, 312 | B6488C4F1D34C00400D6CC32 /* CCDropDownMenus */, 313 | ); 314 | }; 315 | /* End PBXProject section */ 316 | 317 | /* Begin PBXResourcesBuildPhase section */ 318 | B62889081D2FB456009E35E3 /* Resources */ = { 319 | isa = PBXResourcesBuildPhase; 320 | buildActionMask = 2147483647; 321 | files = ( 322 | B62889361D307101009E35E3 /* sun.png in Resources */, 323 | B62889331D307101009E35E3 /* cloud.png in Resources */, 324 | B62889351D307101009E35E3 /* snow.png in Resources */, 325 | B628891D1D2FB456009E35E3 /* LaunchScreen.storyboard in Resources */, 326 | B628891A1D2FB456009E35E3 /* Assets.xcassets in Resources */, 327 | B62889181D2FB456009E35E3 /* Main.storyboard in Resources */, 328 | B628892A1D2FCD02009E35E3 /* arrow.png in Resources */, 329 | B62889341D307101009E35E3 /* rain.png in Resources */, 330 | ); 331 | runOnlyForDeploymentPostprocessing = 0; 332 | }; 333 | B6488C4E1D34C00400D6CC32 /* Resources */ = { 334 | isa = PBXResourcesBuildPhase; 335 | buildActionMask = 2147483647; 336 | files = ( 337 | B6488C5D1D34C0DE00D6CC32 /* arrow.png in Resources */, 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | /* End PBXResourcesBuildPhase section */ 342 | 343 | /* Begin PBXSourcesBuildPhase section */ 344 | B62889061D2FB456009E35E3 /* Sources */ = { 345 | isa = PBXSourcesBuildPhase; 346 | buildActionMask = 2147483647; 347 | files = ( 348 | B62889151D2FB456009E35E3 /* ViewController.m in Sources */, 349 | B62889121D2FB456009E35E3 /* AppDelegate.m in Sources */, 350 | B628890F1D2FB456009E35E3 /* main.m in Sources */, 351 | ); 352 | runOnlyForDeploymentPostprocessing = 0; 353 | }; 354 | B6488C4B1D34C00400D6CC32 /* Sources */ = { 355 | isa = PBXSourcesBuildPhase; 356 | buildActionMask = 2147483647; 357 | files = ( 358 | B6488C5E1D34C0FA00D6CC32 /* CCDropDownMenu.m in Sources */, 359 | B6488C5F1D34C0FA00D6CC32 /* CCDropDownMenuCell.m in Sources */, 360 | B6488C601D34C0FA00D6CC32 /* ManaDropDownMenu.m in Sources */, 361 | B6488C611D34C0FA00D6CC32 /* GaiDropDownMenu.m in Sources */, 362 | B6488C621D34C0FA00D6CC32 /* SyuDropDownMenu.m in Sources */, 363 | ); 364 | runOnlyForDeploymentPostprocessing = 0; 365 | }; 366 | /* End PBXSourcesBuildPhase section */ 367 | 368 | /* Begin PBXTargetDependency section */ 369 | B6488C561D34C00400D6CC32 /* PBXTargetDependency */ = { 370 | isa = PBXTargetDependency; 371 | target = B6488C4F1D34C00400D6CC32 /* CCDropDownMenus */; 372 | targetProxy = B6488C551D34C00400D6CC32 /* PBXContainerItemProxy */; 373 | }; 374 | /* End PBXTargetDependency section */ 375 | 376 | /* Begin PBXVariantGroup section */ 377 | B62889161D2FB456009E35E3 /* Main.storyboard */ = { 378 | isa = PBXVariantGroup; 379 | children = ( 380 | B62889171D2FB456009E35E3 /* Base */, 381 | ); 382 | name = Main.storyboard; 383 | sourceTree = ""; 384 | }; 385 | B628891B1D2FB456009E35E3 /* LaunchScreen.storyboard */ = { 386 | isa = PBXVariantGroup; 387 | children = ( 388 | B628891C1D2FB456009E35E3 /* Base */, 389 | ); 390 | name = LaunchScreen.storyboard; 391 | sourceTree = ""; 392 | }; 393 | /* End PBXVariantGroup section */ 394 | 395 | /* Begin XCBuildConfiguration section */ 396 | B628891F1D2FB456009E35E3 /* Debug */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ALWAYS_SEARCH_USER_PATHS = NO; 400 | CLANG_ANALYZER_NONNULL = YES; 401 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 402 | CLANG_CXX_LIBRARY = "libc++"; 403 | CLANG_ENABLE_MODULES = YES; 404 | CLANG_ENABLE_OBJC_ARC = YES; 405 | CLANG_WARN_BOOL_CONVERSION = YES; 406 | CLANG_WARN_CONSTANT_CONVERSION = YES; 407 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 408 | CLANG_WARN_EMPTY_BODY = YES; 409 | CLANG_WARN_ENUM_CONVERSION = YES; 410 | CLANG_WARN_INT_CONVERSION = YES; 411 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 412 | CLANG_WARN_UNREACHABLE_CODE = YES; 413 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 414 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 415 | COPY_PHASE_STRIP = NO; 416 | DEBUG_INFORMATION_FORMAT = dwarf; 417 | ENABLE_STRICT_OBJC_MSGSEND = YES; 418 | ENABLE_TESTABILITY = YES; 419 | GCC_C_LANGUAGE_STANDARD = gnu99; 420 | GCC_DYNAMIC_NO_PIC = NO; 421 | GCC_NO_COMMON_BLOCKS = YES; 422 | GCC_OPTIMIZATION_LEVEL = 0; 423 | GCC_PREPROCESSOR_DEFINITIONS = ( 424 | "DEBUG=1", 425 | "$(inherited)", 426 | ); 427 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 428 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 429 | GCC_WARN_UNDECLARED_SELECTOR = YES; 430 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 431 | GCC_WARN_UNUSED_FUNCTION = YES; 432 | GCC_WARN_UNUSED_VARIABLE = YES; 433 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 434 | MTL_ENABLE_DEBUG_INFO = YES; 435 | ONLY_ACTIVE_ARCH = YES; 436 | SDKROOT = iphoneos; 437 | }; 438 | name = Debug; 439 | }; 440 | B62889201D2FB456009E35E3 /* Release */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | ALWAYS_SEARCH_USER_PATHS = NO; 444 | CLANG_ANALYZER_NONNULL = YES; 445 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 446 | CLANG_CXX_LIBRARY = "libc++"; 447 | CLANG_ENABLE_MODULES = YES; 448 | CLANG_ENABLE_OBJC_ARC = YES; 449 | CLANG_WARN_BOOL_CONVERSION = YES; 450 | CLANG_WARN_CONSTANT_CONVERSION = YES; 451 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 452 | CLANG_WARN_EMPTY_BODY = YES; 453 | CLANG_WARN_ENUM_CONVERSION = YES; 454 | CLANG_WARN_INT_CONVERSION = YES; 455 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 456 | CLANG_WARN_UNREACHABLE_CODE = YES; 457 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 458 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 459 | COPY_PHASE_STRIP = NO; 460 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 461 | ENABLE_NS_ASSERTIONS = NO; 462 | ENABLE_STRICT_OBJC_MSGSEND = YES; 463 | GCC_C_LANGUAGE_STANDARD = gnu99; 464 | GCC_NO_COMMON_BLOCKS = YES; 465 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 466 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 467 | GCC_WARN_UNDECLARED_SELECTOR = YES; 468 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 469 | GCC_WARN_UNUSED_FUNCTION = YES; 470 | GCC_WARN_UNUSED_VARIABLE = YES; 471 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 472 | MTL_ENABLE_DEBUG_INFO = NO; 473 | SDKROOT = iphoneos; 474 | VALIDATE_PRODUCT = YES; 475 | }; 476 | name = Release; 477 | }; 478 | B62889221D2FB456009E35E3 /* Debug */ = { 479 | isa = XCBuildConfiguration; 480 | buildSettings = { 481 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 482 | CODE_SIGN_IDENTITY = "iPhone Developer"; 483 | INFOPLIST_FILE = "$(SRCROOT)/CCDropDownMenuSample/Info.plist"; 484 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 485 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 486 | PRODUCT_BUNDLE_IDENTIFIER = com.Cokile.CCDropDownMenu; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | }; 489 | name = Debug; 490 | }; 491 | B62889231D2FB456009E35E3 /* Release */ = { 492 | isa = XCBuildConfiguration; 493 | buildSettings = { 494 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 495 | CODE_SIGN_IDENTITY = "iPhone Developer"; 496 | INFOPLIST_FILE = "$(SRCROOT)/CCDropDownMenuSample/Info.plist"; 497 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 498 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 499 | PRODUCT_BUNDLE_IDENTIFIER = com.Cokile.CCDropDownMenu; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | }; 502 | name = Release; 503 | }; 504 | B6488C591D34C00500D6CC32 /* Debug */ = { 505 | isa = XCBuildConfiguration; 506 | buildSettings = { 507 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; 508 | CODE_SIGN_IDENTITY = "iPhone Developer"; 509 | CURRENT_PROJECT_VERSION = 1; 510 | DEFINES_MODULE = YES; 511 | DYLIB_COMPATIBILITY_VERSION = 1; 512 | DYLIB_CURRENT_VERSION = 1; 513 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 514 | INFOPLIST_FILE = CCDropDownMenu/Info.plist; 515 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 516 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 517 | PRODUCT_BUNDLE_IDENTIFIER = com.Cokile.CCDropDownMenus; 518 | PRODUCT_NAME = "$(TARGET_NAME)"; 519 | SKIP_INSTALL = YES; 520 | TARGETED_DEVICE_FAMILY = "1,2"; 521 | VERSIONING_SYSTEM = "apple-generic"; 522 | VERSION_INFO_PREFIX = ""; 523 | }; 524 | name = Debug; 525 | }; 526 | B6488C5A1D34C00500D6CC32 /* Release */ = { 527 | isa = XCBuildConfiguration; 528 | buildSettings = { 529 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; 530 | CODE_SIGN_IDENTITY = "iPhone Developer"; 531 | CURRENT_PROJECT_VERSION = 1; 532 | DEFINES_MODULE = YES; 533 | DYLIB_COMPATIBILITY_VERSION = 1; 534 | DYLIB_CURRENT_VERSION = 1; 535 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 536 | INFOPLIST_FILE = CCDropDownMenu/Info.plist; 537 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 538 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 539 | PRODUCT_BUNDLE_IDENTIFIER = com.Cokile.CCDropDownMenus; 540 | PRODUCT_NAME = "$(TARGET_NAME)"; 541 | SKIP_INSTALL = YES; 542 | TARGETED_DEVICE_FAMILY = "1,2"; 543 | VERSIONING_SYSTEM = "apple-generic"; 544 | VERSION_INFO_PREFIX = ""; 545 | }; 546 | name = Release; 547 | }; 548 | /* End XCBuildConfiguration section */ 549 | 550 | /* Begin XCConfigurationList section */ 551 | B62889051D2FB456009E35E3 /* Build configuration list for PBXProject "CCDropDownMenu" */ = { 552 | isa = XCConfigurationList; 553 | buildConfigurations = ( 554 | B628891F1D2FB456009E35E3 /* Debug */, 555 | B62889201D2FB456009E35E3 /* Release */, 556 | ); 557 | defaultConfigurationIsVisible = 0; 558 | defaultConfigurationName = Release; 559 | }; 560 | B62889211D2FB456009E35E3 /* Build configuration list for PBXNativeTarget "CCDropDownMenuSample" */ = { 561 | isa = XCConfigurationList; 562 | buildConfigurations = ( 563 | B62889221D2FB456009E35E3 /* Debug */, 564 | B62889231D2FB456009E35E3 /* Release */, 565 | ); 566 | defaultConfigurationIsVisible = 0; 567 | defaultConfigurationName = Release; 568 | }; 569 | B6488C5B1D34C00500D6CC32 /* Build configuration list for PBXNativeTarget "CCDropDownMenus" */ = { 570 | isa = XCConfigurationList; 571 | buildConfigurations = ( 572 | B6488C591D34C00500D6CC32 /* Debug */, 573 | B6488C5A1D34C00500D6CC32 /* Release */, 574 | ); 575 | defaultConfigurationIsVisible = 0; 576 | defaultConfigurationName = Release; 577 | }; 578 | /* End XCConfigurationList section */ 579 | }; 580 | rootObject = B62889021D2FB456009E35E3 /* Project object */; 581 | } 582 | -------------------------------------------------------------------------------- /CCDropDownMenu.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CCDropDownMenu.xcodeproj/xcshareddata/xcschemes/CCDropDownMenus.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /CCDropDownMenu/CCDropDownMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // CCDropDownMenu.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | // CCDropDownMenu is the base class for all the drop menus. 9 | // You should not use it directly. 10 | 11 | #import 12 | #import "CCDropDownMenuCell.h" 13 | #import "Rect.h" 14 | 15 | @class CCDropDownMenu; 16 | 17 | #pragma mark - delegate protocol 18 | @protocol CCDropDownMenuDelegate 19 | 20 | @optional 21 | /** 22 | * Tells the delegate that the specified row is now selected. 23 | * 24 | * @param dropDownMenu A drop down menu object informing the delegate about the new row selection. 25 | * @param index An index locating the new selected row in dropDownMenu. 26 | */ 27 | - (void)dropDownMenu:(CCDropDownMenu *)dropDownMenu didSelectRowAtIndex:(NSInteger)index; 28 | 29 | @end 30 | 31 | @interface CCDropDownMenu : UIView 32 | 33 | #pragma mark - Public properties 34 | /** 35 | * The object that acts as the delegate of the drop down menu. 36 | */ 37 | @property (nonatomic, weak) id delegate; 38 | 39 | /** 40 | * The color that applys to the title and the arrow when the drop down menu is expanded. Default value is a orange color. 41 | */ 42 | @property (nonatomic, strong) UIColor *activeColor; 43 | 44 | /** 45 | * The color that applys to the title and the arrow when the drop down menu is closed. Default value is a gray color. 46 | */ 47 | @property (nonatomic, strong) UIColor *inactiveColor; 48 | 49 | /** 50 | * The color that applys to the title view. Default value is a white color. 51 | */ 52 | @property (nonatomic, strong) UIColor *titleViewColor; 53 | 54 | /** 55 | * The image that applys to the right indicator for the drop down menu. Default value is a arrow image. 56 | */ 57 | @property (nonatomic, strong) UIImage *indicator; 58 | 59 | /** 60 | * The boolean value that indicates if the drop down menu is expanded. 61 | */ 62 | @property (nonatomic, getter=isExpanded) BOOL expanded; 63 | 64 | /** 65 | * The value that applys to the number of rows of the drop down menu. 66 | */ 67 | @property (nonatomic) NSInteger numberOfRows; 68 | 69 | /** 70 | * The value that applys to the height for row of the drop down menu. 71 | */ 72 | @property (nonatomic)CGFloat heightOfRows; 73 | 74 | /** 75 | * THe strings that apply to the text for each row. 76 | */ 77 | @property (nonatomic, strong) NSArray *textOfRows; 78 | 79 | /** 80 | * The colors that applys to background color for each row. 81 | */ 82 | @property (nonatomic, strong) NSArray *colorOfRows; 83 | 84 | #pragma mark - Public methods 85 | - (void)cellTapped:(NSNotification *)notification; 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /CCDropDownMenu/CCDropDownMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // CCDropDownMenu.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "CCDropDownMenu.h" 10 | 11 | @interface CCDropDownMenu () 12 | 13 | @end 14 | 15 | @implementation CCDropDownMenu 16 | 17 | #pragma mark - Custom accessorys 18 | - (void)setIndicator:(UIImage *)indicator { 19 | _indicator = [indicator imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 20 | } 21 | 22 | #pragma mark - Lifecycle 23 | - (void)dealloc { 24 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 25 | } 26 | 27 | - (instancetype)initWithFrame:(CGRect)frame { 28 | self = [super initWithFrame:frame]; 29 | 30 | if (self) { 31 | self.expanded = NO; 32 | } 33 | 34 | return self; 35 | } 36 | 37 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 38 | self = [super initWithCoder:aDecoder]; 39 | 40 | if (self) { 41 | self.expanded = NO; 42 | } 43 | 44 | return self; 45 | } 46 | 47 | #pragma mark - Public methods 48 | - (void)cellTapped:(NSNotification *)notification { 49 | NSAssert(NO, @"%@ must be overridden.", NSStringFromSelector(_cmd)); 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /CCDropDownMenu/CCDropDownMenuCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // CCDropDownMenuCell.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface CCDropDownMenuCell : UIView 12 | #pragma mark - Public properties 13 | @property (nonatomic, strong) UIImage *image; 14 | @property (nonatomic, strong) NSString *text; 15 | @property (nonatomic, strong) UIColor *activeColor; 16 | @property (nonatomic, strong) UIColor *inactiveColor; 17 | @property (nonatomic) NSUInteger index; 18 | @property (nonatomic) CGFloat borderWidth; 19 | @property (nonatomic) NSTextAlignment textAligment; 20 | 21 | #pragma mark - Public methods 22 | - (void)removeAllSubviews; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /CCDropDownMenu/CCDropDownMenuCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // CCDropDownMenuCell.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "CCDropDownMenuCell.h" 10 | 11 | @interface CCDropDownMenuCell () 12 | 13 | @property (nonatomic, strong) UIImageView *imageView; 14 | @property (nonatomic, strong) UILabel *textLabel; 15 | @property (nonatomic, strong) UIColor *originalColor; 16 | @property (nonatomic, strong) CALayer *borderLayer; 17 | 18 | @end 19 | 20 | @implementation CCDropDownMenuCell 21 | 22 | #pragma mark - Cunstom accessorys 23 | - (void)setImage:(UIImage *)image { 24 | _image = image; 25 | 26 | self.imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 27 | } 28 | 29 | - (void)setText:(NSString *)text { 30 | _text = text; 31 | 32 | self.textLabel.text = text; 33 | } 34 | 35 | - (void)setActiveColor:(UIColor *)activeColor { 36 | _activeColor = activeColor; 37 | 38 | [self updateForColor:activeColor]; 39 | } 40 | 41 | - (void)setInactiveColor:(UIColor *)inactiveColor { 42 | _inactiveColor = inactiveColor; 43 | 44 | [self updateForColor:inactiveColor]; 45 | } 46 | 47 | - (void)setBorderWidth:(CGFloat)borderWidth { 48 | _borderWidth = borderWidth; 49 | 50 | self.borderLayer.borderWidth = borderWidth; 51 | } 52 | 53 | - (void)setTextAligment:(NSTextAlignment)textAligment { 54 | _textAligment = textAligment; 55 | 56 | self.textLabel.textAlignment = textAligment; 57 | } 58 | 59 | #pragma mark - Lifecycle 60 | - (instancetype)initWithFrame:(CGRect)frame { 61 | self = [super initWithFrame:frame]; 62 | 63 | if (self) { 64 | self.imageView = [[UIImageView alloc] init]; 65 | self.borderLayer = [[CALayer alloc] init]; 66 | 67 | self.textLabel = [[UILabel alloc] init]; 68 | self.textLabel.textAlignment = NSTextAlignmentLeft; 69 | 70 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeOriginalColor:) name:@"cellBackgroundColorChanged" object:self]; 71 | } 72 | 73 | return self; 74 | } 75 | 76 | - (void)dealloc { 77 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 78 | } 79 | 80 | #pragma mark - Overridden methods 81 | - (void)drawRect:(CGRect)rect { 82 | CGFloat length = CGRectGetHeight(self.frame); 83 | 84 | [self removeAllSubviews]; 85 | 86 | self.borderLayer.frame = CGRectMake(8, CGRectGetHeight(self.frame)-0.5, CGRectGetWidth(self.frame)-16, 0.5); 87 | self.borderLayer.borderColor = [UIColor colorWithRed:0.8667 green:0.8667 blue:0.8667 alpha:1.0].CGColor; 88 | [self.layer addSublayer:self.borderLayer]; 89 | 90 | if (self.image) { 91 | self.imageView.frame = CGRectInset(CGRectMake(0, 0, length, length), length*0.2, length*0.2); 92 | [self addSubview:self.imageView]; 93 | 94 | self.textLabel.frame = CGRectMake(length+8, 0, CGRectGetWidth(rect)-length-8, length); 95 | [self addSubview:self.textLabel]; 96 | } else { 97 | self.textLabel.frame = CGRectMake(8, 0, CGRectGetWidth(rect)-16, length); 98 | [self addSubview:self.textLabel]; 99 | } 100 | } 101 | 102 | - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 103 | self.backgroundColor = self.activeColor; 104 | [self updateForColor:self.originalColor]; 105 | } 106 | 107 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 108 | self.backgroundColor = self.originalColor; 109 | [self updateForColor:self.inactiveColor]; 110 | 111 | NSDictionary *userInfo = @{@"index": @(self.index), 112 | @"cell": self}; 113 | [[NSNotificationCenter defaultCenter] postNotificationName:@"CCDropDownMenuCellTapped" object:self userInfo:userInfo]; 114 | } 115 | 116 | #pragma mark - Private methods 117 | - (void)updateForColor:(UIColor *)color { 118 | self.textLabel.textColor = color; 119 | self.imageView.tintColor = color; 120 | } 121 | 122 | - (void)removeAllSubviews { 123 | for (UIView *subView in self.subviews) { 124 | [subView removeFromSuperview]; 125 | } 126 | 127 | [self.borderLayer removeFromSuperlayer]; 128 | } 129 | 130 | - (void)changeOriginalColor:(NSNotification *)notification { 131 | self.originalColor = [(CCDropDownMenuCell *)notification.object backgroundColor]; 132 | } 133 | 134 | @end 135 | -------------------------------------------------------------------------------- /CCDropDownMenu/CCDropDownMenus.h: -------------------------------------------------------------------------------- 1 | // 2 | // CCDropDownMenus.h 3 | // CCDropDownMenus 4 | // 5 | // Created by Kelvin on 7/12/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for CCDropDownMenus. 12 | FOUNDATION_EXPORT double CCDropDownMenusVersionNumber; 13 | 14 | //! Project version string for CCDropDownMenus. 15 | FOUNDATION_EXPORT const unsigned char CCDropDownMenusVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | #import 21 | #import 22 | #import 23 | -------------------------------------------------------------------------------- /CCDropDownMenu/GaiDropDownMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // GaiDropDownMenu.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/12/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "CCDropDownMenu.h" 10 | 11 | @interface GaiDropDownMenu : CCDropDownMenu 12 | 13 | #pragma mark - Public properties 14 | /** 15 | * The color that applys to the seperator for the title and the indicator. Default value is a gray color. 16 | */ 17 | @property (nonatomic, strong) UIColor *seperatorColor; 18 | 19 | /** 20 | * The value that applys to the gutter distance between list view. Default value is 0. 21 | */ 22 | @property (nonatomic) CGFloat gutter; 23 | 24 | /** 25 | * The string that applys to the title of the menu. 26 | */ 27 | @property (nonatomic, strong) NSString *title; 28 | 29 | /** 30 | * The boolean value that indicates that wethter apply a resilient when expansion. Default value is NO. 31 | */ 32 | @property (nonatomic, getter=isResilient) BOOL resilient; 33 | 34 | /** 35 | * The boolean value that indicates that whether the rows show from the same side when expansion. Default value is NO. 36 | */ 37 | @property (nonatomic, getter=doesAppearFromOneSide) BOOL appearFromOneSide; 38 | 39 | /** 40 | * The strings that represent the name of the image for each row. 41 | */ 42 | @property (nonatomic, strong) NSArray *imageNameOfRows; 43 | 44 | #pragma mark - Public methods 45 | - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /CCDropDownMenu/GaiDropDownMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // GaiDropDownMenu.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/12/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "GaiDropDownMenu.h" 10 | 11 | @interface GaiDropDownMenu () { 12 | CGFloat originalHeight; 13 | NSInteger originalIndex; 14 | } 15 | 16 | @property (nonatomic, strong) UIView *titleView; 17 | @property (nonatomic, strong) CALayer *seperatorLayer; 18 | @property (nonatomic, strong) UIImageView *indicatorView; 19 | @property (nonatomic, strong) NSMutableArray *listViews; 20 | @property (nonatomic, strong) UILabel *titleLabel; 21 | @property (nonatomic, strong) CALayer *borderLayer; 22 | 23 | @end 24 | 25 | @implementation GaiDropDownMenu 26 | 27 | @synthesize seperatorColor = _seperatorColor; 28 | @synthesize indicator = _indicator; 29 | @synthesize inactiveColor = _inactiveColor; 30 | @synthesize title = _title; 31 | @synthesize titleViewColor = _titleViewColor; 32 | 33 | #pragma mark - Constants 34 | static CGFloat const seperatorWidth = 1; 35 | 36 | #pragma mark - Custom accessorys 37 | - (void)setGutter:(CGFloat)gutter { 38 | if (gutter < 0) { 39 | _gutter = 0; 40 | } else { 41 | _gutter = gutter; 42 | } 43 | } 44 | 45 | -(void)setTitleViewColor:(UIColor *)titleViewColor { 46 | _titleViewColor = titleViewColor; 47 | self.titleView.backgroundColor = titleViewColor; 48 | } 49 | 50 | - (void)setSeperatorColor:(UIColor *)seperatorColor { 51 | _seperatorColor = seperatorColor; 52 | 53 | self.seperatorLayer.borderColor = seperatorColor.CGColor; 54 | } 55 | 56 | - (void)setIndicator:(UIImage *)indicator { 57 | _indicator = indicator; 58 | 59 | self.indicatorView.image = [indicator imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 60 | } 61 | 62 | - (void)setInactiveColor:(UIColor *)inactiveColor { 63 | _inactiveColor = inactiveColor; 64 | 65 | self.titleLabel.textColor = inactiveColor; 66 | self.indicatorView.tintColor = inactiveColor; 67 | } 68 | 69 | - (void)setTitle:(NSString *)title { 70 | _title = title; 71 | 72 | self.titleLabel.text = title; 73 | } 74 | 75 | - (NSString *)title { 76 | return self.titleLabel.text; 77 | } 78 | 79 | #pragma mark - Lifecycle 80 | - (instancetype)initWithFrame:(CGRect)frame { 81 | self = [super initWithFrame:frame]; 82 | 83 | if (self) { 84 | [self commonInitialization]; 85 | self.heightOfRows = CGRectGetHeight(self.frame); 86 | } 87 | 88 | return self; 89 | } 90 | 91 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 92 | self = [super initWithCoder:aDecoder]; 93 | 94 | if (self) { 95 | [self commonInitialization]; 96 | } 97 | 98 | return self; 99 | } 100 | 101 | #pragma mark - Overridden methods 102 | - (void)drawRect:(CGRect)rect { 103 | CGFloat length = CGRectGetHeight(self.bounds); 104 | originalHeight = length; 105 | 106 | self.titleView.frame = self.bounds; 107 | [self addSubview:self.titleView]; 108 | 109 | self.titleLabel.frame = CGRectMake(8, 4, CGRectGetWidth(self.bounds)-length-8, length-8); 110 | self.titleLabel.textAlignment = NSTextAlignmentLeft; 111 | self.titleLabel.adjustsFontSizeToFitWidth = YES; 112 | [self.titleView addSubview:self.titleLabel]; 113 | 114 | self.indicatorView.frame = CGRectInset(CGRectMake(CGRectGetWidth(self.bounds)-length, 0, length, length), length*0.3, length*0.3); 115 | [self.titleView addSubview:self.indicatorView]; 116 | 117 | CGRect frame = CGRectMake(CGRectGetWidth(self.bounds)-length-seperatorWidth, 0, seperatorWidth, length); 118 | self.seperatorLayer.frame = CGRectInset(frame, 0, length/6); 119 | [self.titleView.layer addSublayer:self.seperatorLayer]; 120 | 121 | self.borderLayer.frame = CGRectMake(8, length-0.5, CGRectGetWidth(self.bounds)-16, 0.5); 122 | self.borderLayer.borderWidth = 0; 123 | [self.titleView.layer addSublayer:self.borderLayer]; 124 | 125 | for (int i = 0; i < self.numberOfRows; i++) { 126 | CGRect frame = CGRectSetHeight(self.titleView.frame, self.heightOfRows); 127 | if (self.doesAppearFromOneSide || i%2 == 0) { 128 | frame = CGRectOffset(frame, -CGRectGetWidth(frame), CGRectGetHeight(self.titleView.frame)+i*self.heightOfRows+(i+1)*self.gutter); 129 | } else { 130 | frame = CGRectOffset(frame, CGRectGetWidth(frame), CGRectGetHeight(self.titleView.frame)+i*self.heightOfRows+(i+1)*self.gutter); 131 | } 132 | CCDropDownMenuCell *cell = [[CCDropDownMenuCell alloc] initWithFrame:frame]; 133 | cell.alpha = 0; 134 | cell.index = i; 135 | cell.textAligment = NSTextAlignmentLeft; 136 | cell.activeColor = self.activeColor; 137 | cell.inactiveColor = self.inactiveColor; 138 | cell.text = [self.textOfRows objectAtIndex:i]; 139 | cell.image = [UIImage imageNamed:[self.imageNameOfRows objectAtIndex:i]]; 140 | cell.backgroundColor = [self.colorOfRows objectAtIndex:i]!=nil?[self.colorOfRows objectAtIndex:i]:self.titleViewColor; 141 | [[NSNotificationCenter defaultCenter] postNotificationName:@"cellBackgroundColorChanged" object:cell]; 142 | 143 | [cell setNeedsDisplay]; 144 | 145 | [self insertSubview:cell atIndex:0]; 146 | [self.listViews addObject:cell]; 147 | } 148 | } 149 | 150 | - (void)titleViewTapped:(UITapGestureRecognizer *)tapGestureRecognizer { 151 | self.isExpanded?[self animateForClose]:[self animateForExpansion]; 152 | [self updateForColor:self.isExpanded?self.inactiveColor:self.activeColor]; 153 | 154 | self.expanded = !self.isExpanded; 155 | } 156 | 157 | - (void)cellTapped:(NSNotification *)notification { 158 | NSDictionary *userInfo = notification.userInfo; 159 | NSInteger index = [[userInfo objectForKey:@"index"] integerValue]; 160 | CCDropDownMenuCell *cell = [userInfo objectForKey:@"cell"]; 161 | 162 | if ([self.listViews containsObject:cell]) { 163 | self.expanded = NO; 164 | self.title = cell.text; 165 | 166 | [self animateForClose]; 167 | [self updateForColor:self.inactiveColor]; 168 | 169 | if ([self.delegate respondsToSelector:@selector(dropDownMenu:didSelectRowAtIndex:)]) { 170 | [self.delegate dropDownMenu:self didSelectRowAtIndex:index]; 171 | } 172 | } 173 | } 174 | 175 | #pragma mark - Public methods 176 | - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title { 177 | self = [self initWithFrame:frame]; 178 | 179 | if (self) { 180 | self.title = title; 181 | } 182 | 183 | return self; 184 | } 185 | 186 | #pragma mark - Private methods 187 | - (void)commonInitialization { 188 | self.titleView = [[UIView alloc] init]; 189 | self.titleLabel = [[UILabel alloc] init]; 190 | self.seperatorLayer = [[CALayer alloc] init]; 191 | self.borderLayer = [[CALayer alloc] init]; 192 | self.indicatorView = [[UIImageView alloc] init]; 193 | self.listViews = [NSMutableArray arrayWithCapacity:1]; 194 | 195 | self.seperatorLayer.cornerRadius = CGRectGetWidth(self.seperatorLayer.frame)/2; 196 | 197 | UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(titleViewTapped:)]; 198 | [self.titleView addGestureRecognizer:tapGestureRecognizer]; 199 | 200 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cellTapped:) name:@"CCDropDownMenuCellTapped" object:nil]; 201 | 202 | self.activeColor = [UIColor colorWithRed:0.902 green:0.4196 blue:0.1255 alpha:1.0]; 203 | self.inactiveColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]; 204 | self.seperatorColor = [UIColor colorWithRed:0.8667 green:0.8667 blue:0.8667 alpha:1.0]; 205 | self.borderLayer.borderColor = self.seperatorColor.CGColor; 206 | self.titleViewColor = [UIColor whiteColor]; 207 | self.backgroundColor = [UIColor clearColor]; 208 | self.indicator = [UIImage imageNamed:@"arrow.png"]; 209 | 210 | self.seperatorLayer.borderWidth = seperatorWidth; 211 | self.gutter = 0.0; 212 | self.resilient = NO; 213 | self.appearFromOneSide = NO; 214 | self.heightOfRows = CGRectGetHeight(self.bounds); 215 | } 216 | 217 | - (void)updateForColor:(UIColor *)color { 218 | self.titleLabel.textColor = color; 219 | self.indicatorView.tintColor = color; 220 | } 221 | 222 | - (void)animateForExpansion { 223 | originalIndex = [self.superview.subviews indexOfObject:self]; 224 | [self.superview bringSubviewToFront:self]; 225 | 226 | NSInteger rows = self.numberOfRows; 227 | CGFloat height = self.heightOfRows; 228 | self.frame = CGRectSetHeight(self.frame, originalHeight+rows*(height+self.gutter)); 229 | 230 | [UIView animateWithDuration:0.2 animations:^{ 231 | self.indicatorView.transform = CGAffineTransformMakeRotation(M_PI); 232 | }]; 233 | 234 | for (CCDropDownMenuCell *cell in self.listViews) { 235 | NSInteger index = [self.listViews indexOfObject:cell]; 236 | 237 | [UIView animateWithDuration:self.isResilient?0.6:0.35 delay:index*0.2 usingSpringWithDamping:self.isResilient?0.55:1 initialSpringVelocity:0 options:kNilOptions animations:^{ 238 | cell.frame = CGRectSetX(cell.frame, 0); 239 | cell.alpha = 1; 240 | if (self.gutter == 0) { 241 | cell.borderWidth = 0.5; 242 | self.borderLayer.borderWidth = 0.5; 243 | } 244 | } completion:nil]; 245 | } 246 | } 247 | 248 | - (void)animateForClose { 249 | for (CCDropDownMenuCell *cell in self.listViews) { 250 | NSInteger index = [self.listViews indexOfObject:cell]; 251 | 252 | [UIView animateWithDuration:0.3 delay:self.doesAppearFromOneSide?index*0.2:0 options:kNilOptions animations:^{ 253 | cell.alpha = 0; 254 | 255 | CGRect frame = CGRectSetHeight(self.titleView.frame, self.heightOfRows); 256 | if (self.doesAppearFromOneSide || index%2 == 0) { 257 | frame = CGRectOffset(frame, -CGRectGetWidth(frame), CGRectGetHeight(self.titleView.frame)+index*self.heightOfRows+(index+1)*self.gutter); 258 | } else { 259 | frame = CGRectOffset(frame, CGRectGetWidth(frame), CGRectGetHeight(self.titleView.frame)+index*self.heightOfRows+(index+1)*self.gutter); 260 | } 261 | cell.frame = frame; 262 | 263 | if (self.gutter == 0) { 264 | cell.borderWidth = 0.0; 265 | self.borderLayer.borderWidth = 0.0; 266 | } 267 | } completion:nil]; 268 | } 269 | 270 | [UIView animateWithDuration:0.2 animations:^{ 271 | self.indicatorView.transform = CGAffineTransformIdentity; 272 | } completion:^(BOOL finished) { 273 | [self.superview insertSubview:self atIndex:originalIndex]; 274 | self.frame = CGRectSetHeight(self.frame, originalHeight); 275 | }]; 276 | } 277 | 278 | @end 279 | -------------------------------------------------------------------------------- /CCDropDownMenu/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CCDropDownMenu/ManaDropDownMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // ManaDropDownMenu.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/9/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "CCDropDownMenu.h" 10 | 11 | @interface ManaDropDownMenu : CCDropDownMenu 12 | 13 | #pragma mark - Public properties 14 | /** 15 | * The color that applys to the seperator for the title and the indicator. Default value is a gray color. 16 | */ 17 | @property (nonatomic, strong) UIColor *seperatorColor; 18 | 19 | /** 20 | * The value that applys to the gutter distance between list view. Default value is 0. 21 | */ 22 | @property (nonatomic) CGFloat gutter; 23 | 24 | /** 25 | * The string that applys to the title of the menu. 26 | */ 27 | @property (nonatomic, strong) NSString *title; 28 | 29 | /** 30 | * The boolean value that indicates the weahter apply a resilient when expansion. Default value is NO. 31 | */ 32 | @property (nonatomic, getter=isResilient) BOOL resilient; 33 | 34 | /** 35 | * The strings that represent the name of the image for each row. 36 | */ 37 | @property (nonatomic, strong) NSArray *imageNameOfRows; 38 | 39 | #pragma mark - Public methods 40 | - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /CCDropDownMenu/ManaDropDownMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // ManaDropDownMenu.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/9/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "ManaDropDownMenu.h" 10 | 11 | @interface ManaDropDownMenu () { 12 | CGFloat originalHeight; 13 | NSInteger originalIndex; 14 | } 15 | 16 | @property (nonatomic, strong) UIView *titleView; 17 | @property (nonatomic, strong) CALayer *seperatorLayer; 18 | @property (nonatomic, strong) UIImageView *indicatorView; 19 | @property (nonatomic, strong) NSMutableArray *listViews; 20 | @property (nonatomic, strong) UILabel *titleLabel; 21 | @property (nonatomic, strong) CALayer *borderLayer; 22 | 23 | 24 | @end 25 | 26 | @implementation ManaDropDownMenu 27 | 28 | @synthesize seperatorColor = _seperatorColor; 29 | @synthesize indicator = _indicator; 30 | @synthesize inactiveColor = _inactiveColor; 31 | @synthesize title = _title; 32 | @synthesize titleViewColor = _titleViewColor; 33 | 34 | #pragma mark - Constants 35 | static CGFloat const seperatorWidth = 1; 36 | 37 | #pragma mark - Custom accessorys 38 | - (void)setGutter:(CGFloat)gutter { 39 | if (gutter < 0) { 40 | _gutter = 0; 41 | } else { 42 | _gutter = gutter; 43 | } 44 | } 45 | 46 | -(void)setTitleViewColor:(UIColor *)titleViewColor { 47 | _titleViewColor = titleViewColor; 48 | self.titleView.backgroundColor = titleViewColor; 49 | } 50 | 51 | - (void)setSeperatorColor:(UIColor *)seperatorColor { 52 | _seperatorColor = seperatorColor; 53 | 54 | self.seperatorLayer.borderColor = seperatorColor.CGColor; 55 | } 56 | 57 | - (void)setIndicator:(UIImage *)indicator { 58 | _indicator = indicator; 59 | 60 | self.indicatorView.image = [indicator imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 61 | } 62 | 63 | - (void)setInactiveColor:(UIColor *)inactiveColor { 64 | _inactiveColor = inactiveColor; 65 | 66 | self.titleLabel.textColor = inactiveColor; 67 | self.indicatorView.tintColor = inactiveColor; 68 | } 69 | 70 | - (void)setTitle:(NSString *)title { 71 | _title = title; 72 | 73 | self.titleLabel.text = title; 74 | } 75 | 76 | - (NSString *)title { 77 | return self.titleLabel.text; 78 | } 79 | 80 | #pragma mark - Lifecycle 81 | - (instancetype)initWithFrame:(CGRect)frame { 82 | self = [super initWithFrame:frame]; 83 | 84 | if (self) { 85 | [self commonInitialization]; 86 | self.heightOfRows = CGRectGetHeight(self.frame); 87 | } 88 | 89 | return self; 90 | } 91 | 92 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 93 | self = [super initWithCoder:aDecoder]; 94 | 95 | if (self) { 96 | [self commonInitialization]; 97 | } 98 | 99 | return self; 100 | } 101 | 102 | #pragma mark - Overridden methods 103 | - (void)drawRect:(CGRect)rect { 104 | CGFloat length = CGRectGetHeight(self.bounds); 105 | originalHeight = length; 106 | 107 | self.titleView.frame = self.bounds; 108 | [self addSubview:self.titleView]; 109 | 110 | self.titleLabel.frame = CGRectMake(8, 4, CGRectGetWidth(self.bounds)-length-8, length-8); 111 | self.titleLabel.textAlignment = NSTextAlignmentLeft; 112 | self.titleLabel.adjustsFontSizeToFitWidth = YES; 113 | [self.titleView addSubview:self.titleLabel]; 114 | 115 | self.indicatorView.frame = CGRectInset(CGRectMake(CGRectGetWidth(self.bounds)-length, 0, length, length), length*0.3, length*0.3); 116 | [self.titleView addSubview:self.indicatorView]; 117 | 118 | CGRect frame = CGRectMake(CGRectGetWidth(self.bounds)-length-seperatorWidth, 0, seperatorWidth, length); 119 | self.seperatorLayer.frame = CGRectInset(frame, 0, length/6); 120 | [self.titleView.layer addSublayer:self.seperatorLayer]; 121 | 122 | self.borderLayer.frame = CGRectMake(8, length-0.5, CGRectGetWidth(self.bounds)-16, 0.5); 123 | self.borderLayer.borderWidth = 0; 124 | [self.titleView.layer addSublayer:self.borderLayer]; 125 | 126 | for (int i = 0; i < self.numberOfRows; i++) { 127 | CCDropDownMenuCell *cell = [[CCDropDownMenuCell alloc] initWithFrame:self.titleView.bounds]; 128 | cell.index = i; 129 | cell.textAligment = NSTextAlignmentLeft; 130 | cell.activeColor = self.activeColor; 131 | cell.inactiveColor = self.inactiveColor; 132 | cell.text = [self.textOfRows objectAtIndex:i]; 133 | cell.image = [UIImage imageNamed:[self.imageNameOfRows objectAtIndex:i]]; 134 | cell.backgroundColor = [self.colorOfRows objectAtIndex:i]!=nil?[self.colorOfRows objectAtIndex:i]:self.titleViewColor; 135 | [[NSNotificationCenter defaultCenter] postNotificationName:@"cellBackgroundColorChanged" object:cell]; 136 | 137 | [cell setNeedsDisplay]; 138 | 139 | [self insertSubview:cell atIndex:0]; 140 | [self.listViews addObject:cell]; 141 | } 142 | } 143 | 144 | - (void)titleViewTapped:(UITapGestureRecognizer *)tapGestureRecognizer { 145 | self.isExpanded?[self animateForClose]:[self animateForExpansion]; 146 | [self updateForColor:self.isExpanded?self.inactiveColor:self.activeColor]; 147 | 148 | self.expanded = !self.isExpanded; 149 | } 150 | 151 | - (void)cellTapped:(NSNotification *)notification { 152 | NSDictionary *userInfo = notification.userInfo; 153 | NSInteger index = [[userInfo objectForKey:@"index"] integerValue]; 154 | CCDropDownMenuCell *cell = [userInfo objectForKey:@"cell"]; 155 | 156 | if ([self.listViews containsObject:cell]) { 157 | self.expanded = NO; 158 | self.title = cell.text; 159 | 160 | [self animateForClose]; 161 | [self updateForColor:self.inactiveColor]; 162 | 163 | if ([self.delegate respondsToSelector:@selector(dropDownMenu:didSelectRowAtIndex:)]) { 164 | [self.delegate dropDownMenu:self didSelectRowAtIndex:index]; 165 | } 166 | } 167 | } 168 | 169 | #pragma mark - Public methods 170 | - (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title { 171 | self = [self initWithFrame:frame]; 172 | 173 | if (self) { 174 | self.title = title; 175 | } 176 | 177 | return self; 178 | } 179 | 180 | #pragma mark - Private methods 181 | - (void)commonInitialization { 182 | self.titleView = [[UIView alloc] init]; 183 | self.titleLabel = [[UILabel alloc] init]; 184 | self.seperatorLayer = [[CALayer alloc] init]; 185 | self.borderLayer = [[CALayer alloc] init]; 186 | self.indicatorView = [[UIImageView alloc] init]; 187 | self.listViews = [NSMutableArray arrayWithCapacity:1]; 188 | 189 | self.seperatorLayer.cornerRadius = CGRectGetWidth(self.seperatorLayer.frame)/2; 190 | 191 | UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(titleViewTapped:)]; 192 | [self.titleView addGestureRecognizer:tapGestureRecognizer]; 193 | 194 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cellTapped:) name:@"CCDropDownMenuCellTapped" object:nil]; 195 | 196 | self.activeColor = [UIColor colorWithRed:0.902 green:0.4196 blue:0.1255 alpha:1.0]; 197 | self.inactiveColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]; 198 | self.seperatorColor = [UIColor colorWithRed:0.8667 green:0.8667 blue:0.8667 alpha:1.0]; 199 | self.borderLayer.borderColor = self.seperatorColor.CGColor; 200 | self.titleViewColor = [UIColor whiteColor]; 201 | self.backgroundColor = [UIColor clearColor]; 202 | self.indicator = [UIImage imageNamed:@"arrow.png"]; 203 | 204 | self.seperatorLayer.borderWidth = seperatorWidth; 205 | self.gutter = 0.0; 206 | self.resilient = NO; 207 | self.heightOfRows = CGRectGetHeight(self.bounds); 208 | } 209 | 210 | - (void)updateForColor:(UIColor *)color { 211 | self.titleLabel.textColor = color; 212 | self.indicatorView.tintColor = color; 213 | } 214 | 215 | - (void)animateForExpansion { 216 | originalIndex = [self.superview.subviews indexOfObject:self]; 217 | [self.superview bringSubviewToFront:self]; 218 | 219 | NSInteger rows = self.numberOfRows; 220 | CGFloat height = self.heightOfRows; 221 | self.frame = CGRectSetHeight(self.frame, originalHeight+rows*(height+self.gutter)); 222 | 223 | [UIView animateWithDuration:0.2 animations:^{ 224 | self.indicatorView.transform = CGAffineTransformMakeRotation(M_PI); 225 | }]; 226 | 227 | for (CCDropDownMenuCell *cell in self.listViews) { 228 | NSInteger index = [self.listViews indexOfObject:cell]; 229 | [UIView animateWithDuration:self.isResilient?0.6:0.35 delay:0 usingSpringWithDamping:self.isResilient?0.55:1 initialSpringVelocity:0 options:kNilOptions animations:^{ 230 | cell.frame = CGRectSetHeight(cell.frame, height); 231 | [cell setNeedsDisplay]; 232 | cell.frame = CGRectOffset(cell.frame, 0, CGRectGetHeight(self.titleView.frame)+index*height+(index+1)*self.gutter); 233 | 234 | if (self.gutter == 0) { 235 | cell.borderWidth = 0.5; 236 | self.borderLayer.borderWidth = 0.5; 237 | } 238 | } completion:nil]; 239 | } 240 | } 241 | 242 | - (void)animateForClose { 243 | for (CCDropDownMenuCell *cell in self.listViews) { 244 | [cell removeAllSubviews]; 245 | 246 | [UIView animateWithDuration:0.25 animations:^{ 247 | cell.frame = self.titleView.bounds; 248 | 249 | if (self.gutter == 0) { 250 | cell.borderWidth = 0.0; 251 | self.borderLayer.borderWidth = 0.0; 252 | } 253 | }]; 254 | } 255 | 256 | [UIView animateWithDuration:0.2 animations:^{ 257 | self.indicatorView.transform = CGAffineTransformIdentity; 258 | } completion:^(BOOL finished) { 259 | [self.superview insertSubview:self atIndex:originalIndex]; 260 | self.frame = CGRectSetHeight(self.frame, originalHeight); 261 | }]; 262 | } 263 | 264 | @end 265 | -------------------------------------------------------------------------------- /CCDropDownMenu/Rect.h: -------------------------------------------------------------------------------- 1 | // 2 | // Rect.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/9/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #ifndef Rect_h 10 | #define Rect_h 11 | 12 | #define CGRectSetWidth(rect, width) CGRectMake(rect.origin.x, rect.origin.y, width, rect.size.height) 13 | 14 | #define CGRectSetHeight(rect, height) CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, height) 15 | 16 | #define CGRectSetSize(rect, size) CGRectMake(rect.origin.x, rect.origin.y, size.width, size.height) 17 | 18 | #define CGRectSetX(rect, x) CGRectMake(x, rect.origin.y, rect.size.width, rect.size.height) 19 | 20 | #define CGRectSetY(rect, y) CGRectMake(rect.origin.x, y, rect.size.width, rect.size.height) 21 | 22 | #define CGRectSetOrigin(rect, origin) CGRectMake(origin.x, origin.y, rect.size.width, rect.size.height) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /CCDropDownMenu/SyuDropDownMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // SyuDropDownMenu.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/11/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "CCDropDownMenu.h" 10 | 11 | @interface SyuDropDownMenu : CCDropDownMenu 12 | 13 | #pragma mark - Public properties 14 | /** 15 | * The value that applys to the gutter distance between list view. Default value is 0. 16 | */ 17 | @property (nonatomic) CGFloat gutter; 18 | 19 | /** 20 | * The boolean value that indicates the weahter apply a resilient when expansion. Default value is NO. 21 | */ 22 | @property (nonatomic, getter=isResilient) BOOL resilient; 23 | 24 | #pragma mark - Public methods 25 | - (instancetype)initWithNavigationBar:(UINavigationBar *)navigationBar useNavigationController:(BOOL)doesUseNavigationCOntroller; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /CCDropDownMenu/SyuDropDownMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // SyuDropDownMenu.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/11/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "SyuDropDownMenu.h" 10 | 11 | @interface SyuDropDownMenu () { 12 | CGFloat originalHeight; 13 | NSInteger originalIndex; 14 | } 15 | 16 | @property (nonatomic, strong) UIView *titleView; 17 | @property (nonatomic, strong) CALayer *seperatorLayer; 18 | @property (nonatomic, strong) UIImageView *indicatorView; 19 | @property (nonatomic, strong) NSMutableArray *listViews; 20 | @property (nonatomic, strong) UILabel *titleLabel; 21 | @property (nonatomic, strong) CALayer *borderLayer; 22 | @property (nonatomic, strong) UINavigationBar *navigationBar; 23 | 24 | 25 | @end 26 | 27 | @implementation SyuDropDownMenu 28 | 29 | @synthesize indicator = _indicator; 30 | @synthesize inactiveColor = _inactiveColor; 31 | 32 | #pragma mark - Custom accessorys 33 | - (void)setGutter:(CGFloat)gutter { 34 | if (gutter < 0) { 35 | _gutter = 0; 36 | } else { 37 | _gutter = gutter; 38 | } 39 | } 40 | 41 | - (void)setIndicator:(UIImage *)indicator { 42 | _indicator = indicator; 43 | 44 | self.indicatorView.image = [indicator imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 45 | } 46 | 47 | - (void)setInactiveColor:(UIColor *)inactiveColor { 48 | _inactiveColor = inactiveColor; 49 | 50 | self.indicatorView.tintColor = inactiveColor; 51 | } 52 | 53 | #pragma mark - Lifecycle 54 | - (instancetype)initWithFrame:(CGRect)frame { 55 | self = [super initWithFrame:frame]; 56 | 57 | if (self) { 58 | [self commonInitialization]; 59 | } 60 | 61 | return self; 62 | } 63 | 64 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 65 | self = [super initWithCoder:aDecoder]; 66 | 67 | if (self) { 68 | [self commonInitialization]; 69 | } 70 | 71 | return self; 72 | } 73 | 74 | #pragma mark - Overridden methods 75 | - (void)drawRect:(CGRect)rect { 76 | CGFloat length = CGRectGetHeight(self.bounds); 77 | originalHeight = length; 78 | 79 | self.titleView.frame = self.bounds; 80 | [self addSubview:self.titleView]; 81 | 82 | self.indicatorView.frame = CGRectInset(CGRectMake((CGRectGetWidth(self.titleView.frame)-length)/2, 0, length, length), 0, 0); 83 | [self.titleView addSubview:self.indicatorView]; 84 | 85 | self.borderLayer.frame = CGRectMake(8, length-0.5, CGRectGetWidth(self.bounds)-16, 0.5); 86 | self.borderLayer.borderWidth = 0; 87 | [self.titleView.layer addSublayer:self.borderLayer]; 88 | 89 | for (int i = 0; i < self.numberOfRows; i++) { 90 | CCDropDownMenuCell *cell = [[CCDropDownMenuCell alloc] initWithFrame:self.titleView.bounds]; 91 | cell.index = i; 92 | cell.textAligment = NSTextAlignmentCenter; 93 | cell.activeColor = self.activeColor; 94 | cell.inactiveColor = self.inactiveColor; 95 | cell.text = [self.textOfRows objectAtIndex:i]; 96 | cell.backgroundColor = [self.colorOfRows objectAtIndex:i]?[self.colorOfRows objectAtIndex:i]:self.titleView.backgroundColor; 97 | [[NSNotificationCenter defaultCenter] postNotificationName:@"cellBackgroundColorChanged" object:cell]; 98 | 99 | [cell setNeedsDisplay]; 100 | 101 | [self insertSubview:cell atIndex:0]; 102 | [self.listViews addObject:cell]; 103 | } 104 | } 105 | 106 | - (void)titleViewTapped:(UITapGestureRecognizer *)tapGestureRecognizer { 107 | self.isExpanded?[self animateForClose]:[self animateForExpansion]; 108 | 109 | self.expanded = !self.isExpanded; 110 | } 111 | 112 | - (void)cellTapped:(NSNotification *)notification { 113 | NSDictionary *userInfo = notification.userInfo; 114 | NSInteger index = [[userInfo objectForKey:@"index"] integerValue]; 115 | CCDropDownMenuCell *cell = [userInfo objectForKey:@"cell"]; 116 | 117 | if ([self.listViews containsObject:cell]) { 118 | self.expanded = NO; 119 | self.navigationBar.topItem.title = cell.text; 120 | 121 | [self animateForClose]; 122 | 123 | 124 | if ([self.delegate respondsToSelector:@selector(dropDownMenu:didSelectRowAtIndex:)]) { 125 | [self.delegate dropDownMenu:self didSelectRowAtIndex:index]; 126 | } 127 | } 128 | } 129 | 130 | #pragma mark - Public methods 131 | - (instancetype)initWithNavigationBar:(UINavigationBar *)navigationBar useNavigationController:(BOOL)doesUseNavigationCOntroller { 132 | [navigationBar setTranslucent:NO]; 133 | [navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; 134 | [navigationBar setShadowImage:[[UIImage alloc] init]]; 135 | [navigationBar setTitleVerticalPositionAdjustment:10 forBarMetrics:UIBarMetricsDefault]; 136 | 137 | CGFloat originY = doesUseNavigationCOntroller?0:CGRectGetHeight(navigationBar.frame); 138 | self = [self initWithFrame:CGRectMake(0, originY, CGRectGetWidth([UIScreen mainScreen].bounds), 10)]; 139 | 140 | if (self) { 141 | self.titleView.backgroundColor = navigationBar.barTintColor; 142 | self.navigationBar = navigationBar; 143 | } 144 | 145 | return self; 146 | } 147 | 148 | #pragma mark - Private methods 149 | - (void)commonInitialization { 150 | self.titleView = [[UIView alloc] init]; 151 | self.borderLayer = [[CALayer alloc] init]; 152 | self.indicatorView = [[UIImageView alloc] init]; 153 | self.listViews = [NSMutableArray arrayWithCapacity:1]; 154 | self.navigationBar = [[UINavigationBar alloc] init]; 155 | 156 | UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(titleViewTapped:)]; 157 | [self.titleView addGestureRecognizer:tapGestureRecognizer]; 158 | 159 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cellTapped:) name:@"CCDropDownMenuCellTapped" object:nil]; 160 | 161 | self.activeColor = [UIColor colorWithRed:0.8261 green:0.85 blue:0.8682 alpha:1.0]; 162 | self.inactiveColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:1.0]; 163 | self.borderLayer.borderColor = [UIColor colorWithRed:0.8667 green:0.8667 blue:0.8667 alpha:1.0].CGColor; 164 | self.titleViewColor = [UIColor whiteColor]; 165 | self.backgroundColor = [UIColor clearColor]; 166 | self.indicator = [UIImage imageNamed:@"arrow.png"]; 167 | 168 | self.gutter = 0.0; 169 | self.resilient = NO; 170 | self.heightOfRows = 37; 171 | } 172 | 173 | 174 | - (void)animateForExpansion { 175 | originalIndex = [self.superview.subviews indexOfObject:self]; 176 | [self.superview bringSubviewToFront:self]; 177 | 178 | NSInteger rows = self.numberOfRows; 179 | CGFloat height = self.heightOfRows; 180 | self.frame = CGRectSetHeight(self.frame, originalHeight+rows*(height+self.gutter)); 181 | 182 | [UIView animateWithDuration:0.2 animations:^{ 183 | self.indicatorView.transform = CGAffineTransformMakeRotation(M_PI); 184 | }]; 185 | 186 | for (CCDropDownMenuCell *cell in self.listViews) { 187 | NSInteger index = [self.listViews indexOfObject:cell]; 188 | [UIView animateWithDuration:self.isResilient?0.6:0.35 delay:0 usingSpringWithDamping:self.isResilient?0.55:1 initialSpringVelocity:0 options:kNilOptions animations:^{ 189 | cell.frame = CGRectSetHeight(cell.frame, height); 190 | [cell setNeedsDisplay]; 191 | cell.frame = CGRectOffset(cell.frame, 0, CGRectGetHeight(self.titleView.frame)+index*height+(index+1)*self.gutter); 192 | 193 | if (self.gutter == 0) { 194 | cell.borderWidth = 0.5; 195 | self.borderLayer.borderWidth = 0.5; 196 | } 197 | } completion:nil]; 198 | } 199 | } 200 | 201 | - (void)animateForClose { 202 | for (CCDropDownMenuCell *cell in self.listViews) { 203 | [cell removeAllSubviews]; 204 | 205 | [UIView animateWithDuration:0.25 animations:^{ 206 | cell.frame = self.titleView.bounds; 207 | 208 | if (self.gutter == 0) { 209 | cell.borderWidth = 0.0; 210 | self.borderLayer.borderWidth = 0.0; 211 | } 212 | }]; 213 | } 214 | 215 | [UIView animateWithDuration:0.2 animations:^{ 216 | self.indicatorView.transform = CGAffineTransformIdentity; 217 | } completion:^(BOOL finished) { 218 | [self.superview insertSubview:self atIndex:originalIndex]; 219 | self.frame = CGRectSetHeight(self.frame, originalHeight); 220 | }]; 221 | } 222 | 223 | @end 224 | 225 | -------------------------------------------------------------------------------- /CCDropDownMenu/arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/CCDropDownMenu/arrow.png -------------------------------------------------------------------------------- /CCDropDownMenuSample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. 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 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. 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 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /CCDropDownMenuSample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | 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 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | 12 | @interface ViewController () 13 | 14 | @property (nonatomic, strong) ManaDropDownMenu *menu1; 15 | @property (nonatomic, strong) GaiDropDownMenu *menu2; 16 | @property (nonatomic, strong) SyuDropDownMenu *menu3; 17 | @property (weak, nonatomic) IBOutlet UINavigationBar *naviBar; 18 | 19 | @end 20 | 21 | @implementation ViewController 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | // Do any additional setup after loading the view, typically from a nib. 26 | 27 | self.view.backgroundColor = [UIColor colorWithRed:0.861 green:0.8599 blue:0.8538 alpha:1.0]; 28 | 29 | CGRect frame = CGRectMake((CGRectGetWidth(self.view.frame)-240)/2, 80, 240, 37); 30 | 31 | self.menu1 = [[ManaDropDownMenu alloc] initWithFrame:frame title:@"Choose a weather"]; 32 | self.menu1.delegate = self; 33 | self.menu1.numberOfRows = 3; 34 | self.menu1.textOfRows = @[@"Facebook", @"Twitter", @"Weibo"]; 35 | //self.menu1.heightOfRows = 50; 36 | //self.menu1.gutter = 5; 37 | //self.menu1.resilient = YES; 38 | [self.view addSubview:self.menu1]; 39 | 40 | self.menu2 = [[GaiDropDownMenu alloc] initWithFrame:CGRectOffset(frame, 0, 240) title:@"Choose a network"]; 41 | self.menu2.delegate = self; 42 | self.menu2.numberOfRows = 4; 43 | self.menu2.imageNameOfRows = @[@"sun", @"cloud", @"rain", @"snow"]; 44 | self.menu2.textOfRows = @[@"sun", @"cloud", @"rain", @"snow"]; 45 | //self.menu2.heightOfRows = 50; 46 | //self.menu2.gutter = 5; 47 | //self.menu2.resilient = YES; 48 | //self.menu2.appearFromOneSide = YES; 49 | [self.view addSubview:self.menu2]; 50 | 51 | self.menu3 = [[SyuDropDownMenu alloc] initWithNavigationBar:self.naviBar useNavigationController:NO]; 52 | self.menu3.delegate = self; 53 | self.menu3.numberOfRows = 3; 54 | self.menu3.activeColor = [UIColor whiteColor]; 55 | self.menu3.textOfRows = @[@"Inbox", @"Unread", @"Starred"]; 56 | UIColor *sampleColor = [UIColor colorWithRed:0.2824 green:0.2824 blue:0.2863 alpha:1.0]; 57 | self.menu3.colorOfRows = @[sampleColor, sampleColor, sampleColor]; 58 | //self.menu3.heightOfRows = 40; 59 | //self.menu3.gutter = 5; 60 | //self.menu3.resilient = YES; 61 | [self.view addSubview:self.menu3]; 62 | } 63 | 64 | - (void)dropDownMenu:(CCDropDownMenu *)dropDownMenu didSelectRowAtIndex:(NSInteger)index { 65 | if (dropDownMenu == self.menu1 || dropDownMenu == self.menu2) { 66 | NSLog(@"%@", ((ManaDropDownMenu *)dropDownMenu).title); 67 | } 68 | 69 | if (dropDownMenu == self.menu3) { 70 | NSLog(@"%lu", (long)index); 71 | } 72 | } 73 | 74 | @end 75 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/CCDropDownMenuSample/cloud.png -------------------------------------------------------------------------------- /CCDropDownMenuSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CCDropDownMenu 4 | // 5 | // Created by Kelvin on 7/8/16. 6 | // Copyright © 2016 Cokile. 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 | -------------------------------------------------------------------------------- /CCDropDownMenuSample/rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/CCDropDownMenuSample/rain.png -------------------------------------------------------------------------------- /CCDropDownMenuSample/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/CCDropDownMenuSample/snow.png -------------------------------------------------------------------------------- /CCDropDownMenuSample/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/CCDropDownMenuSample/sun.png -------------------------------------------------------------------------------- /CCDropDownMenus.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'CCDropDownMenus' 3 | spec.platform = :ios 4 | spec.version = '0.1.2' 5 | spec.license = { :type => 'MIT' } 6 | spec.homepage = 'https://github.com/Cokile/CCDropDownMenu' 7 | spec.authors = { 'Cokile' => 'kelvintgx@gmail.com' } 8 | spec.summary = 'Beautiful drop down menus, written in Objective-C.' 9 | spec.source = {:git => 'https://github.com/Cokile/CCDropDownMenu.git', :tag => 'v0.1.2'} 10 | spec.source_files = 'CCDropDownMenu/*.{h,m}' 11 | spec.resources = 'CCDropDownMenu/*.png' 12 | spec.requires_arc = true 13 | end 14 | -------------------------------------------------------------------------------- /Captures/capture1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/Captures/capture1.gif -------------------------------------------------------------------------------- /Captures/capture2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/Captures/capture2.gif -------------------------------------------------------------------------------- /Captures/capture3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cokile/CCDropDownMenu/a4e1a1fb20e895689107843d3e7c6387db7f82eb/Captures/capture3.gif -------------------------------------------------------------------------------- /Licence: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2016 Runqiu Xu. 3 | This code is distributed under the terms and conditions of the MIT license. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in the 7 | Software without restriction, including without limitation the rights to use, copy, 8 | modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 | and to permit persons to whom the Software is furnished to do so, subject to the 10 | 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 IMPLIED, 16 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 17 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 18 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 19 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 20 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## CCDropDownMenu 2 | 3 | [![](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Cokile/CCActivityIndicatorView/blob/master/Licence) 4 | [![](https://img.shields.io/github/release/Cokile/CCDropDownMenu.svg)](https://github.com/Cokile/CCDropDownMenu/releases) 5 | [![](https://img.shields.io/cocoapods/v/CCDropDownMenus.svg)](https://img.shields.io/cocoapods/v/CCDropDownMenus.svg) 6 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 7 | 8 | `CCDropDownMenu` now features 9 | 10 | | Type | 11 | | :--------------------------------------: | 12 | | [ManaDropDownMenu](https://github.com/Cokile/CCDropDownMenu#manadropdownmenu) | 13 | | [GaiDropDownMenu](https://github.com/Cokile/CCDropDownMenu#gaidropdownmenu) | 14 | | [SyuDropDownMenu](https://github.com/Cokile/CCDropDownMenu#syudropdownmenu) | 15 | 16 | 17 | 18 | ## Installation 19 | 20 | ### Cocoapods 21 | 22 | ```ruby 23 | pod 'CCDropDownMenus' 24 | ``` 25 | 26 | ### Carthage 27 | 28 | ```ruby 29 | github "Cokile/CCDropDownMenu" 30 | ``` 31 | 32 | ### Manually 33 | 34 | Add all the files in the `CCDropDownMenu` folder to your project. 35 | 36 | 37 | 38 | ## ManaDropDownMenu 39 | 40 | ![](Captures/capture1.gif) 41 | 42 | ### Easy to use 43 | 44 | ```objective-c 45 | #import 46 | 47 | // ... 48 | @interface ViewController () 49 | 50 | // ... 51 | - (void)viewDidLoad { 52 | // ... 53 | ManaDropDownMenu *menu = [[ManaDropDownMenu alloc] initWithFrame:<#CGRect#> title:<#NSString#>]; 54 | menu.delegate = self; 55 | menu.numberOfRows = <#NSInteger#>; 56 | menu.textOfRows = @[<#NSString#>, <#NSString#>, <#NSString#>, ...]; 57 | [self.view addSubview:menu]; 58 | } 59 | 60 | - (void)dropDownMenu:(CCDropDownMenu *)dropDownMenu didSelectRowAtIndex:(NSInteger)index { 61 | // ... 62 | } 63 | ``` 64 | 65 | ### Customisable 66 | 67 | ```objective-c 68 | // The color that applys to the title and the arrow when the drop down menu is expanded. Default value is a orange color. 69 | menu.activeColor = <#UIColor#>; 70 | 71 | // The color that applys to the title and the arrow when the drop down menu is closed. Default value is a gray color. 72 | menu.inactiveColor = <#UIColor#>; 73 | 74 | // The color that applys to the seperator for the title and the indicator. Default value is a gray color. 75 | menu.seperatorColor = <#UIColor#>; 76 | 77 | // The color that applys to the title view. Default value is a white color. 78 | menu.titleViewColor = <#UIColor#>; 79 | 80 | // The string that applys to the title for the drop down menu. 81 | menu.title = <#NSString#>; 82 | 83 | // The image that applys to the right indicator for the drop down menu. Default value is a arrow image. 84 | menu.indicator = <#UIImage#>; 85 | 86 | // The value that applys to the gutter distance between list view. Default value is 0. 87 | menu.gutter = <#CGFloat#>; 88 | 89 | // The boolean value that indicates the weahter apply a resilient when expansion. Default value is NO. 90 | // Getter is isResilient 91 | menu.resilient = <#BOOL#>; 92 | 93 | // The value that applys to the height for row of the drop down menu. 94 | menu.heightOfRows = <#CGFloat#>; 95 | 96 | // The strings that represent the name of the image for each row. 97 | menu.imageNameOfRows = @[<#NSString#>, @<#NSString#>, <#NSString#>, ...]; 98 | 99 | // The colors that applys to background color for each row. 100 | menu.colorOfRows = @[<#UIColor#>, <#UIColor#>, <#UIColor#>, ...]; 101 | ``` 102 | 103 | 104 | 105 | ## GaiDropDownMenu 106 | 107 | ![](Captures/capture3.gif) 108 | 109 | ### Easy to use 110 | 111 | ```objective-c 112 | #import 113 | 114 | // ... 115 | @interface ViewController () 116 | 117 | // ... 118 | - (void)viewDidLoad { 119 | // ... 120 | GaiDropDownMenu *menu = [[GaiDropDownMenu alloc] initWithFrame:<#CGRect#> title:<#NSString#>]; 121 | menu.delegate = self; 122 | menu.numberOfRows = <#NSInteger#>; 123 | menu.textOfRows = @[<#NSString#>, <#NSString#>, <#NSString#>, ...]; 124 | [self.view addSubview:menu]; 125 | } 126 | 127 | - (void)dropDownMenu:(CCDropDownMenu *)dropDownMenu didSelectRowAtIndex:(NSInteger)index { 128 | // ... 129 | } 130 | ``` 131 | 132 | ### Customisable 133 | 134 | ```objective-c 135 | // The color that applys to the title and the arrow when the drop down menu is expanded. Default value is a orange color. 136 | menu.activeColor = <#UIColor#>; 137 | 138 | // The color that applys to the title and the arrow when the drop down menu is closed. Default value is a gray color. 139 | menu.inactiveColor = <#UIColor#>; 140 | 141 | // The color that applys to the seperator for the title and the indicator. Default value is a gray color. 142 | menu.seperatorColor = <#UIColor#>; 143 | 144 | // The color that applys to the title view. Default value is a white color. 145 | menu.titleViewColor = <#UIColor#>; 146 | 147 | // The string that applys to the title for the drop down menu. 148 | menu.title = <#NSString#>; 149 | 150 | // The image that applys to the right indicator for the drop down menu. Default value is a arrow image. 151 | menu.indicator = <#UIImage#>; 152 | 153 | // The value that applys to the gutter distance between list view. Default value is 0. 154 | menu.gutter = <#CGFloat#>; 155 | 156 | // The boolean value that indicates the weahter apply a resilient when expansion. Default value is NO. 157 | // Getter is isResilient 158 | menu.resilient = <#BOOL#>; 159 | 160 | // The boolean value that indicates that whether the rows show from the same side when expansion. Default value is NO. 161 | // Getter is doesAppearFromOneSide 162 | menu.appearFromOneSide = <#BOOL#>; 163 | 164 | // The value that applys to the height for row of the drop down menu. 165 | menu.heightOfRows = <#CGFloat#>; 166 | 167 | // The strings that represent the name of the image for each row. 168 | menu.imageNameOfRows = @[<#NSString#>, @<#NSString#>, <#NSString#>, ...]; 169 | 170 | // The colors that applys to background color for each row. 171 | menu.colorOfRows = @[<#UIColor#>, <#UIColor#>, <#UIColor#>, ...]; 172 | ``` 173 | 174 | 175 | 176 | ## SyuDropDownMenu 177 | 178 | ![](Captures/capture2.gif) 179 | 180 | ### Easy to use 181 | 182 | ```objective-c 183 | #import 184 | 185 | // ... 186 | @interface ViewController () 187 | 188 | // ... 189 | - (void)viewDidLoad { 190 | // ... 191 | // You should set the batTintColor of the navigation first. 192 | // If the view controller is embeded into a UINavigationController, you should pass YES to the second parameter, otherwise pass NO. 193 | SyuDropDownMenu *menu = [[SyuDropDownMenu alloc] initWithNavigationBar:<#UINavigationBar#> useNavigationController:<#BOOL#>; 194 | menu.delegate = self; 195 | menu.numberOfRows = <#NSInteger#>; 196 | menu.textOfRows = @[<#NSString#>, <#NSString#>, <#NSString#>, ...]; 197 | [self.view addSubview:menu]; 198 | } 199 | 200 | - (void)dropDownMenu:(CCDropDownMenu *)dropDownMenu didSelectRowAtIndex:(NSInteger)index { 201 | // ... 202 | } 203 | ``` 204 | 205 | ### Customisable 206 | 207 | ```objective-c 208 | // The color that applys to the title and the arrow when the drop down menu is expanded. Default value is a light blue color. 209 | menu.activeColor = <#UIColor#>; 210 | 211 | // The color that applys to the title and the arrow when the drop down menu is closed. Default value is a gray color. 212 | menu.inactiveColor = <#UIColor#>; 213 | 214 | // The color that applys to the title view. Default value is the bar tint color of the navigation bar. 215 | menu.titleViewColor = <#UIColor#>; 216 | 217 | // The image that applys to the right indicator for the drop down menu. Default value is a arrow image. 218 | menu.indicator = <#UIImage#>; 219 | 220 | // The value that applys to the gutter distance between list view. Default value is 0. 221 | menu.gutter = <#CGFloat#>; 222 | 223 | // The boolean value that indicates the weahter apply a resilient when expansion. Default value is NO. 224 | // Getter is isResilient 225 | menu.resilient = <#BOOL#>; 226 | 227 | // The value that applys to the height for row of the drop down menu. 228 | menu.heightOfRows = <#CGFloat#>; 229 | 230 | // The colors that applys to background color for each row. 231 | menu.colorOfRows = @[<#UIColor#>, <#UIColor#>, <#UIColor#>, ...]; 232 | ``` 233 | 234 | 235 | 236 | ## Requirement 237 | 238 | CCDropDownMenu requires ARC. 239 | 240 | 241 | 242 | ## TODO 243 | 244 | - More types of drop down menu. 245 | - Performance improvement 246 | 247 | 248 | 249 | Any Pull Requests and issues are welcome. 250 | --------------------------------------------------------------------------------