├── .gitignore ├── CFDropDownMenuView.podspec ├── CFDropDownMenuView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── CFDropDownMenuView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── 测试黄.imageset │ │ ├── Contents.json │ │ ├── 黄箭头@2x.png │ │ └── 黄箭头@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CFDropDownMenuView │ ├── CFDropDownMenuView.bundle │ │ ├── 天蓝箭头@2x.png │ │ ├── 天蓝箭头@3x.png │ │ ├── 橙箭头@2x.png │ │ ├── 橙箭头@3x.png │ │ ├── 淡紫箭头@2x.png │ │ ├── 淡紫箭头@3x.png │ │ ├── 深灰箭头@2x.png │ │ ├── 深灰箭头@3x.png │ │ ├── 深绿箭头@2x.png │ │ ├── 深绿箭头@3x.png │ │ ├── 深蓝箭头@2x.png │ │ ├── 深蓝箭头@3x.png │ │ ├── 灰箭头@2x.png │ │ ├── 灰箭头@3x.png │ │ ├── 白箭头@2x.png │ │ ├── 白箭头@3x.png │ │ ├── 粉箭头@2x.png │ │ ├── 粉箭头@3x.png │ │ ├── 紫箭头@2x.png │ │ ├── 紫箭头@3x.png │ │ ├── 红箭头@2x.png │ │ ├── 红箭头@3x.png │ │ ├── 绿箭头@2x.png │ │ ├── 绿箭头@3x.png │ │ ├── 黄箭头@2x.png │ │ └── 黄箭头@3x.png │ └── Lib │ │ ├── CFDropDownMenuView.h │ │ ├── CFDropDownMenuView.m │ │ ├── CFLabelOnLeftButton.h │ │ ├── CFLabelOnLeftButton.m │ │ ├── CFMacro.h │ │ ├── UIView+CFFrame.h │ │ └── UIView+CFFrame.m ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m ├── LICENSE ├── README.md └── showdemo.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /CFDropDownMenuView.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = 'CFDropDownMenuView' 4 | s.version = '0.0.3' 5 | s.summary = '简单实用的下拉列表菜单控件' 6 | s.description = <<-DESC 7 | "下拉列表菜单控件, 支持单列 多列条件选择" 8 | DESC 9 | s.homepage = 'https://github.com/CoderPeak/CFDropDownMenuView' 10 | s.license = 'MIT' 11 | s.authors = {'CoderPeak' => '545486205@qq.com'} 12 | s.platform = :ios, '6.0' 13 | s.source = {:git => 'https://github.com/CoderPeak/CFDropDownMenuView.git' , :tag => s.version.to_s} 14 | s.source_files = 'CFDropDownMenuView/CFDropDownMenuView/**/*.{h,m}' 15 | s.resource = 'CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle' 16 | s.requires_arc = true 17 | end -------------------------------------------------------------------------------- /CFDropDownMenuView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8A22D3CB1D00444A0091EFD7 /* CFDropDownMenuView.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 8A22D3CA1D00444A0091EFD7 /* CFDropDownMenuView.bundle */; }; 11 | 8A4E91741CF95CC4001ED333 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A4E91731CF95CC4001ED333 /* main.m */; }; 12 | 8A4E91771CF95CC4001ED333 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A4E91761CF95CC4001ED333 /* AppDelegate.m */; }; 13 | 8A4E917A1CF95CC4001ED333 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A4E91791CF95CC4001ED333 /* ViewController.m */; }; 14 | 8A4E917D1CF95CC4001ED333 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A4E917B1CF95CC4001ED333 /* Main.storyboard */; }; 15 | 8A4E917F1CF95CC4001ED333 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8A4E917E1CF95CC4001ED333 /* Assets.xcassets */; }; 16 | 8A4E91821CF95CC4001ED333 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8A4E91801CF95CC4001ED333 /* LaunchScreen.storyboard */; }; 17 | 8A4E918E1CF96239001ED333 /* CFDropDownMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A4E918D1CF96239001ED333 /* CFDropDownMenuView.m */; }; 18 | 8A4E91911CF9636F001ED333 /* CFLabelOnLeftButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A4E91901CF9636F001ED333 /* CFLabelOnLeftButton.m */; }; 19 | 8A4E91951CF967AE001ED333 /* UIView+CFFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A4E91941CF967AE001ED333 /* UIView+CFFrame.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 8A22D3CA1D00444A0091EFD7 /* CFDropDownMenuView.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = CFDropDownMenuView.bundle; sourceTree = ""; }; 24 | 8A4E916F1CF95CC4001ED333 /* CFDropDownMenuView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CFDropDownMenuView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 8A4E91731CF95CC4001ED333 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 26 | 8A4E91751CF95CC4001ED333 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 27 | 8A4E91761CF95CC4001ED333 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 28 | 8A4E91781CF95CC4001ED333 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 29 | 8A4E91791CF95CC4001ED333 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 30 | 8A4E917C1CF95CC4001ED333 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 31 | 8A4E917E1CF95CC4001ED333 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 32 | 8A4E91811CF95CC4001ED333 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 33 | 8A4E91831CF95CC4001ED333 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 8A4E918C1CF96239001ED333 /* CFDropDownMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFDropDownMenuView.h; sourceTree = ""; }; 35 | 8A4E918D1CF96239001ED333 /* CFDropDownMenuView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CFDropDownMenuView.m; sourceTree = ""; }; 36 | 8A4E918F1CF9636F001ED333 /* CFLabelOnLeftButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFLabelOnLeftButton.h; sourceTree = ""; }; 37 | 8A4E91901CF9636F001ED333 /* CFLabelOnLeftButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CFLabelOnLeftButton.m; sourceTree = ""; }; 38 | 8A4E91921CF965C1001ED333 /* CFMacro.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CFMacro.h; sourceTree = ""; }; 39 | 8A4E91931CF967AE001ED333 /* UIView+CFFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+CFFrame.h"; sourceTree = ""; }; 40 | 8A4E91941CF967AE001ED333 /* UIView+CFFrame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+CFFrame.m"; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 8A4E916C1CF95CC4001ED333 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | /* End PBXFrameworksBuildPhase section */ 52 | 53 | /* Begin PBXGroup section */ 54 | 8A4E91661CF95CC4001ED333 = { 55 | isa = PBXGroup; 56 | children = ( 57 | 8A4E91711CF95CC4001ED333 /* CFDropDownMenuView */, 58 | 8A4E91701CF95CC4001ED333 /* Products */, 59 | ); 60 | sourceTree = ""; 61 | }; 62 | 8A4E91701CF95CC4001ED333 /* Products */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | 8A4E916F1CF95CC4001ED333 /* CFDropDownMenuView.app */, 66 | ); 67 | name = Products; 68 | sourceTree = ""; 69 | }; 70 | 8A4E91711CF95CC4001ED333 /* CFDropDownMenuView */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 8A4E91891CF96115001ED333 /* CFDropDownMenuView */, 74 | 8A4E91751CF95CC4001ED333 /* AppDelegate.h */, 75 | 8A4E91761CF95CC4001ED333 /* AppDelegate.m */, 76 | 8A4E91781CF95CC4001ED333 /* ViewController.h */, 77 | 8A4E91791CF95CC4001ED333 /* ViewController.m */, 78 | 8A4E917B1CF95CC4001ED333 /* Main.storyboard */, 79 | 8A4E917E1CF95CC4001ED333 /* Assets.xcassets */, 80 | 8A4E91801CF95CC4001ED333 /* LaunchScreen.storyboard */, 81 | 8A4E91831CF95CC4001ED333 /* Info.plist */, 82 | 8A4E91721CF95CC4001ED333 /* Supporting Files */, 83 | ); 84 | path = CFDropDownMenuView; 85 | sourceTree = ""; 86 | }; 87 | 8A4E91721CF95CC4001ED333 /* Supporting Files */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | 8A4E91731CF95CC4001ED333 /* main.m */, 91 | ); 92 | name = "Supporting Files"; 93 | sourceTree = ""; 94 | }; 95 | 8A4E91891CF96115001ED333 /* CFDropDownMenuView */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 8A22D3CA1D00444A0091EFD7 /* CFDropDownMenuView.bundle */, 99 | 8A4E918A1CF96115001ED333 /* Lib */, 100 | ); 101 | path = CFDropDownMenuView; 102 | sourceTree = ""; 103 | }; 104 | 8A4E918A1CF96115001ED333 /* Lib */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | 8A4E918C1CF96239001ED333 /* CFDropDownMenuView.h */, 108 | 8A4E918D1CF96239001ED333 /* CFDropDownMenuView.m */, 109 | 8A4E918F1CF9636F001ED333 /* CFLabelOnLeftButton.h */, 110 | 8A4E91901CF9636F001ED333 /* CFLabelOnLeftButton.m */, 111 | 8A4E91921CF965C1001ED333 /* CFMacro.h */, 112 | 8A4E91931CF967AE001ED333 /* UIView+CFFrame.h */, 113 | 8A4E91941CF967AE001ED333 /* UIView+CFFrame.m */, 114 | ); 115 | path = Lib; 116 | sourceTree = ""; 117 | }; 118 | /* End PBXGroup section */ 119 | 120 | /* Begin PBXNativeTarget section */ 121 | 8A4E916E1CF95CC4001ED333 /* CFDropDownMenuView */ = { 122 | isa = PBXNativeTarget; 123 | buildConfigurationList = 8A4E91861CF95CC4001ED333 /* Build configuration list for PBXNativeTarget "CFDropDownMenuView" */; 124 | buildPhases = ( 125 | 8A4E916B1CF95CC4001ED333 /* Sources */, 126 | 8A4E916C1CF95CC4001ED333 /* Frameworks */, 127 | 8A4E916D1CF95CC4001ED333 /* Resources */, 128 | ); 129 | buildRules = ( 130 | ); 131 | dependencies = ( 132 | ); 133 | name = CFDropDownMenuView; 134 | productName = CFDropDownMenuView; 135 | productReference = 8A4E916F1CF95CC4001ED333 /* CFDropDownMenuView.app */; 136 | productType = "com.apple.product-type.application"; 137 | }; 138 | /* End PBXNativeTarget section */ 139 | 140 | /* Begin PBXProject section */ 141 | 8A4E91671CF95CC4001ED333 /* Project object */ = { 142 | isa = PBXProject; 143 | attributes = { 144 | LastUpgradeCheck = 0730; 145 | ORGANIZATIONNAME = "陈峰"; 146 | TargetAttributes = { 147 | 8A4E916E1CF95CC4001ED333 = { 148 | CreatedOnToolsVersion = 7.3; 149 | }; 150 | }; 151 | }; 152 | buildConfigurationList = 8A4E916A1CF95CC4001ED333 /* Build configuration list for PBXProject "CFDropDownMenuView" */; 153 | compatibilityVersion = "Xcode 3.2"; 154 | developmentRegion = English; 155 | hasScannedForEncodings = 0; 156 | knownRegions = ( 157 | en, 158 | Base, 159 | ); 160 | mainGroup = 8A4E91661CF95CC4001ED333; 161 | productRefGroup = 8A4E91701CF95CC4001ED333 /* Products */; 162 | projectDirPath = ""; 163 | projectRoot = ""; 164 | targets = ( 165 | 8A4E916E1CF95CC4001ED333 /* CFDropDownMenuView */, 166 | ); 167 | }; 168 | /* End PBXProject section */ 169 | 170 | /* Begin PBXResourcesBuildPhase section */ 171 | 8A4E916D1CF95CC4001ED333 /* Resources */ = { 172 | isa = PBXResourcesBuildPhase; 173 | buildActionMask = 2147483647; 174 | files = ( 175 | 8A4E91821CF95CC4001ED333 /* LaunchScreen.storyboard in Resources */, 176 | 8A4E917F1CF95CC4001ED333 /* Assets.xcassets in Resources */, 177 | 8A4E917D1CF95CC4001ED333 /* Main.storyboard in Resources */, 178 | 8A22D3CB1D00444A0091EFD7 /* CFDropDownMenuView.bundle in Resources */, 179 | ); 180 | runOnlyForDeploymentPostprocessing = 0; 181 | }; 182 | /* End PBXResourcesBuildPhase section */ 183 | 184 | /* Begin PBXSourcesBuildPhase section */ 185 | 8A4E916B1CF95CC4001ED333 /* Sources */ = { 186 | isa = PBXSourcesBuildPhase; 187 | buildActionMask = 2147483647; 188 | files = ( 189 | 8A4E917A1CF95CC4001ED333 /* ViewController.m in Sources */, 190 | 8A4E91951CF967AE001ED333 /* UIView+CFFrame.m in Sources */, 191 | 8A4E918E1CF96239001ED333 /* CFDropDownMenuView.m in Sources */, 192 | 8A4E91771CF95CC4001ED333 /* AppDelegate.m in Sources */, 193 | 8A4E91911CF9636F001ED333 /* CFLabelOnLeftButton.m in Sources */, 194 | 8A4E91741CF95CC4001ED333 /* main.m in Sources */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXSourcesBuildPhase section */ 199 | 200 | /* Begin PBXVariantGroup section */ 201 | 8A4E917B1CF95CC4001ED333 /* Main.storyboard */ = { 202 | isa = PBXVariantGroup; 203 | children = ( 204 | 8A4E917C1CF95CC4001ED333 /* Base */, 205 | ); 206 | name = Main.storyboard; 207 | sourceTree = ""; 208 | }; 209 | 8A4E91801CF95CC4001ED333 /* LaunchScreen.storyboard */ = { 210 | isa = PBXVariantGroup; 211 | children = ( 212 | 8A4E91811CF95CC4001ED333 /* Base */, 213 | ); 214 | name = LaunchScreen.storyboard; 215 | sourceTree = ""; 216 | }; 217 | /* End PBXVariantGroup section */ 218 | 219 | /* Begin XCBuildConfiguration section */ 220 | 8A4E91841CF95CC4001ED333 /* Debug */ = { 221 | isa = XCBuildConfiguration; 222 | buildSettings = { 223 | ALWAYS_SEARCH_USER_PATHS = NO; 224 | CLANG_ANALYZER_NONNULL = YES; 225 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 226 | CLANG_CXX_LIBRARY = "libc++"; 227 | CLANG_ENABLE_MODULES = YES; 228 | CLANG_ENABLE_OBJC_ARC = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_CONSTANT_CONVERSION = YES; 231 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 232 | CLANG_WARN_EMPTY_BODY = YES; 233 | CLANG_WARN_ENUM_CONVERSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 236 | CLANG_WARN_UNREACHABLE_CODE = YES; 237 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 238 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 239 | COPY_PHASE_STRIP = NO; 240 | DEBUG_INFORMATION_FORMAT = dwarf; 241 | ENABLE_STRICT_OBJC_MSGSEND = YES; 242 | ENABLE_TESTABILITY = YES; 243 | GCC_C_LANGUAGE_STANDARD = gnu99; 244 | GCC_DYNAMIC_NO_PIC = NO; 245 | GCC_NO_COMMON_BLOCKS = YES; 246 | GCC_OPTIMIZATION_LEVEL = 0; 247 | GCC_PREPROCESSOR_DEFINITIONS = ( 248 | "DEBUG=1", 249 | "$(inherited)", 250 | ); 251 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 252 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 253 | GCC_WARN_UNDECLARED_SELECTOR = YES; 254 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 255 | GCC_WARN_UNUSED_FUNCTION = YES; 256 | GCC_WARN_UNUSED_VARIABLE = YES; 257 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 258 | MTL_ENABLE_DEBUG_INFO = YES; 259 | ONLY_ACTIVE_ARCH = YES; 260 | SDKROOT = iphoneos; 261 | }; 262 | name = Debug; 263 | }; 264 | 8A4E91851CF95CC4001ED333 /* Release */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_ANALYZER_NONNULL = YES; 269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 270 | CLANG_CXX_LIBRARY = "libc++"; 271 | CLANG_ENABLE_MODULES = YES; 272 | CLANG_ENABLE_OBJC_ARC = YES; 273 | CLANG_WARN_BOOL_CONVERSION = YES; 274 | CLANG_WARN_CONSTANT_CONVERSION = YES; 275 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 276 | CLANG_WARN_EMPTY_BODY = YES; 277 | CLANG_WARN_ENUM_CONVERSION = YES; 278 | CLANG_WARN_INT_CONVERSION = YES; 279 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 280 | CLANG_WARN_UNREACHABLE_CODE = YES; 281 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 282 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 283 | COPY_PHASE_STRIP = NO; 284 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 285 | ENABLE_NS_ASSERTIONS = NO; 286 | ENABLE_STRICT_OBJC_MSGSEND = YES; 287 | GCC_C_LANGUAGE_STANDARD = gnu99; 288 | GCC_NO_COMMON_BLOCKS = YES; 289 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 290 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 291 | GCC_WARN_UNDECLARED_SELECTOR = YES; 292 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 293 | GCC_WARN_UNUSED_FUNCTION = YES; 294 | GCC_WARN_UNUSED_VARIABLE = YES; 295 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 296 | MTL_ENABLE_DEBUG_INFO = NO; 297 | SDKROOT = iphoneos; 298 | VALIDATE_PRODUCT = YES; 299 | }; 300 | name = Release; 301 | }; 302 | 8A4E91871CF95CC4001ED333 /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 306 | INFOPLIST_FILE = CFDropDownMenuView/Info.plist; 307 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 308 | PRODUCT_BUNDLE_IDENTIFIER = com.CoderPeak.CFDropDownMenuView; 309 | PRODUCT_NAME = "$(TARGET_NAME)"; 310 | }; 311 | name = Debug; 312 | }; 313 | 8A4E91881CF95CC4001ED333 /* Release */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 317 | INFOPLIST_FILE = CFDropDownMenuView/Info.plist; 318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 319 | PRODUCT_BUNDLE_IDENTIFIER = com.CoderPeak.CFDropDownMenuView; 320 | PRODUCT_NAME = "$(TARGET_NAME)"; 321 | }; 322 | name = Release; 323 | }; 324 | /* End XCBuildConfiguration section */ 325 | 326 | /* Begin XCConfigurationList section */ 327 | 8A4E916A1CF95CC4001ED333 /* Build configuration list for PBXProject "CFDropDownMenuView" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | 8A4E91841CF95CC4001ED333 /* Debug */, 331 | 8A4E91851CF95CC4001ED333 /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | 8A4E91861CF95CC4001ED333 /* Build configuration list for PBXNativeTarget "CFDropDownMenuView" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 8A4E91871CF95CC4001ED333 /* Debug */, 340 | 8A4E91881CF95CC4001ED333 /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | /* End XCConfigurationList section */ 346 | }; 347 | rootObject = 8A4E91671CF95CC4001ED333 /* Project object */; 348 | } 349 | -------------------------------------------------------------------------------- /CFDropDownMenuView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CFDropDownMenuView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. 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 | -------------------------------------------------------------------------------- /CFDropDownMenuView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. 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 | -------------------------------------------------------------------------------- /CFDropDownMenuView/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 | } -------------------------------------------------------------------------------- /CFDropDownMenuView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CFDropDownMenuView/Assets.xcassets/测试黄.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "黄箭头@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "黄箭头@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /CFDropDownMenuView/Assets.xcassets/测试黄.imageset/黄箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/Assets.xcassets/测试黄.imageset/黄箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/Assets.xcassets/测试黄.imageset/黄箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/Assets.xcassets/测试黄.imageset/黄箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/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 | -------------------------------------------------------------------------------- /CFDropDownMenuView/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 | -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/天蓝箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/天蓝箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/天蓝箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/天蓝箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/橙箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/橙箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/橙箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/橙箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/淡紫箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/淡紫箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/淡紫箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/淡紫箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深灰箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深灰箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深灰箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深灰箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深绿箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深绿箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深绿箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深绿箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深蓝箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深蓝箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深蓝箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/深蓝箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/灰箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/灰箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/灰箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/灰箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/白箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/白箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/白箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/白箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/粉箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/粉箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/粉箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/粉箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/紫箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/紫箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/紫箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/紫箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/红箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/红箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/红箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/红箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/绿箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/绿箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/绿箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/绿箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/黄箭头@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/黄箭头@2x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/黄箭头@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/CFDropDownMenuView/CFDropDownMenuView/CFDropDownMenuView.bundle/黄箭头@3x.png -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/Lib/CFDropDownMenuView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CFDropDownMenuView.h 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "CFLabelOnLeftButton.h" 11 | 12 | @class CFDropDownMenuView; 13 | 14 | @protocol CFDropDownMenuViewDelegate 15 | 16 | @optional 17 | 18 | - (void)dropDownMenuView:(CFDropDownMenuView *)dropDownMenuView clickOnCurrentButtonWithTitle:(NSString *)currentTitle andCurrentTitleArray:(NSArray *)currentTitleArray; 19 | 20 | @end 21 | 22 | @interface CFDropDownMenuView : UIView 23 | /** 24 | * 提供两种方式处理筛选条件后的业务逻辑(回调方式) - 代理/block 二选一 25 | */ 26 | /* block 点击选择条件按钮 调用 */ 27 | typedef void (^ChooseConditionBlock)(NSString *, NSArray *); 28 | /* 代理 */ 29 | @property (nonatomic, weak) id delegate; 30 | @property (nonatomic, copy) ChooseConditionBlock chooseConditionBlock; 31 | 32 | /** 33 | * 数据源--二维数组 34 | * 每一个大分类里, 都可以有很多个小分类(条件) 35 | */ 36 | @property (nonatomic, strong) NSMutableArray *dataSourceArr; 37 | 38 | /* 默认显示的 */ 39 | @property (nonatomic, strong) NSArray *defaulTitleArray; 40 | 41 | /* 分类按钮 数组 */ 42 | @property (nonatomic, strong) NSMutableArray *titleBtnArr; 43 | 44 | /* 分类内容 动画起始位置 */ 45 | @property (nonatomic, assign) CGFloat startY; 46 | 47 | /* 选中状态和未选中状态 48 | * 默认 选中状态:蓝色文字,蓝色箭头 49 | * 未选中状态:黑色文字,黑色箭头 50 | * 使用注意: 参数格式 51 | @{ 52 | @"selected" : @[[UIColor BlueColor], @"蓝箭头"], // 选中状态 53 | @"normal" : @[[UIColor BlackColor], @"黑箭头"] // 未选中状态 54 | }; 55 | 可以不传 / 也可以只传其中一对键值对 / 也可以都传 (key必须为@"selected" @"normal") 56 | */ 57 | @property (nonatomic, strong) NSDictionary *stateConfigDict; 58 | 59 | /** 60 | * 公有方法, 供外界使用 61 | */ 62 | - (void)show; 63 | 64 | @end 65 | 66 | -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/Lib/CFDropDownMenuView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CFDropDownMenuView.m 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // 8 | 9 | #import "CFDropDownMenuView.h" 10 | #import "CFMacro.h" 11 | #import "UIView+CFFrame.h" 12 | 13 | #define kTitleBarHeight 45 14 | #define kViewTagConstant 1 // 所有tag都加上这个 防止出现为0的tag 15 | 16 | @interface CFDropDownMenuView () 17 | 18 | /* 分类 classifyView */ 19 | @property (nonatomic, strong) UIView *titleBar; 20 | 21 | /* 整个屏幕的 背景 半透明View */ 22 | @property (nonatomic, strong) UIView *bgView; 23 | 24 | /** 25 | * cell为筛选的条件 26 | */ 27 | @property (nonatomic, strong) UITableView *dropDownMenuTableView; 28 | 29 | /** 30 | * 数据源--一维数组 (每一列的条件标题) 31 | */ 32 | @property (nonatomic, strong) NSArray *dataSource; 33 | 34 | /* 最后点击的按钮 */ 35 | @property (nonatomic, strong) UIButton *lastClickedBtn; 36 | 37 | @end 38 | 39 | 40 | @implementation CFDropDownMenuView 41 | 42 | - (instancetype)initWithFrame:(CGRect)frame 43 | { 44 | if (self = [super initWithFrame:frame]) { 45 | self.backgroundColor = [UIColor clearColor]; 46 | [self addSubview:self.titleBar]; 47 | } 48 | return self; 49 | } 50 | 51 | 52 | 53 | #pragma mark - lazy 54 | /* 分类 classifyView */ 55 | - (UIView *)titleBar 56 | { 57 | if (!_titleBar) { 58 | _titleBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CFScreenWidth, kTitleBarHeight)]; 59 | _titleBar.backgroundColor = [UIColor whiteColor]; 60 | } 61 | return _titleBar; 62 | } 63 | 64 | #pragma mark - setter 65 | - (void)setDataSourceArr:(NSMutableArray *)dataSourceArr 66 | { 67 | _dataSourceArr = dataSourceArr; 68 | 69 | self.titleBtnArr = [[NSMutableArray alloc] init]; 70 | 71 | CGFloat btnW = CFScreenWidth/dataSourceArr.count; 72 | CGFloat btnH = kTitleBarHeight; 73 | 74 | for (NSInteger i=0; i 10 | 11 | @interface CFLabelOnLeftButton : UIButton 12 | 13 | + (instancetype)createButtonWithImageName:(NSString *)imgName title:(NSString *)title titleColor:(UIColor *)titleColor frame:(CGRect)btnFrame target:(id)target action:(SEL)action; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/Lib/CFLabelOnLeftButton.m: -------------------------------------------------------------------------------- 1 | // 2 | // CFLabelOnLeftButton.m 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // 8 | 9 | #import "CFLabelOnLeftButton.h" 10 | #import "CFMacro.h" 11 | #import "UIView+CFFrame.h" 12 | 13 | 14 | @implementation CFLabelOnLeftButton 15 | 16 | - (instancetype)initWithFrame:(CGRect)frame 17 | { 18 | if (self = [super initWithFrame:frame]) { 19 | self.titleLabel.textAlignment = NSTextAlignmentCenter; 20 | 21 | // 默认设置 22 | [self setTitleColor:CF_Color_TextGrayColor forState:UIControlStateNormal]; 23 | self.titleLabel.font = CF_Font_15; 24 | 25 | 26 | } 27 | return self; 28 | } 29 | 30 | + (instancetype)createButtonWithImageName:(NSString *)imgName title:(NSString *)title titleColor:(UIColor *)titleColor frame:(CGRect)btnFrame target:(id)target action:(SEL)action 31 | { 32 | CFLabelOnLeftButton *btn = [self buttonWithType:UIButtonTypeCustom]; 33 | 34 | [btn setTitle:title forState:UIControlStateNormal]; 35 | btn.titleLabel.textAlignment = NSTextAlignmentCenter; 36 | 37 | [btn setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal]; 38 | [btn setTitleColor:titleColor forState:UIControlStateNormal]; 39 | 40 | [btn sizeToFit]; 41 | btn.frame = btnFrame; 42 | [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; 43 | 44 | return btn; 45 | } 46 | 47 | - (void)layoutSubviews 48 | { 49 | [super layoutSubviews]; 50 | 51 | 52 | CGFloat imageWidth = self.imageView.cf_width+1; 53 | CGFloat labelWidth = self.titleLabel.cf_width+1; 54 | 55 | // 图片 位置(右) 56 | self.imageEdgeInsets = UIEdgeInsetsMake(0, labelWidth, 0, -labelWidth); 57 | 58 | 59 | // 文字 位置(左边) 60 | self.titleEdgeInsets = UIEdgeInsetsMake(0, -imageWidth, 0, imageWidth); 61 | 62 | 63 | } 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/Lib/CFMacro.h: -------------------------------------------------------------------------------- 1 | // 2 | // CFMacro.h 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // 8 | 9 | #ifndef CFMacro_h 10 | #define CFMacro_h 11 | 12 | /** 13 | * 资源图片路径相关 宏 14 | */ 15 | #define CFDrowMenuViewSrcName(file) [@"CFDropDownMenuView.bundle" stringByAppendingPathComponent:file] 16 | #define CFDrowMenuViewFrameworkSrcName(file) [@"Frameworks/CFDropDownMenuView.framework/CFDropDownMenuView.bundle" stringByAppendingPathComponent:file] 17 | 18 | /** 19 | * 颜色相关 宏 20 | */ 21 | #define UIColorFromHex(hexValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 green:((float)((hexValue & 0xFF00) >> 8))/255.0 blue:((float)(hexValue & 0xFF))/255.0 alpha:1.0] 22 | #define CF_Color_TextLightGrayColor UIColorFromHex(0x999999) 23 | #define CF_Color_TextGrayColor UIColorFromHex(0x666666) 24 | #define CF_Color_TextDarkGrayColor UIColorFromHex(0x333333) 25 | #define CF_Color_SepertLineColor UIColorFromHex(0xdddddd) 26 | #define CF_Color_DefaultColor UIColorFromHex(0x1e8cd4) // 默认的颜色-蓝 27 | #define CF_Color_DefalutBackGroundColor UIColorFromHex(0xf2f2f2) 28 | 29 | #define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a] 30 | #define RGB(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1.0f] 31 | // 随机色 32 | #define CFRandomColor RGBA(arc4random_uniform(255), arc4random_uniform(255), arc4random_uniform(255), 1.0) 33 | 34 | /** 35 | * 字体相关 宏 36 | */ 37 | #define CF_Font_15 [UIFont systemFontOfSize:15] 38 | 39 | /** 40 | * 尺寸相关 宏 41 | */ 42 | #define CFScreenWidth ([UIScreen mainScreen].bounds.size.width) 43 | #define CFScreenHeight ([UIScreen mainScreen].bounds.size.height) 44 | 45 | #endif /* CFMacro_h */ -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/Lib/UIView+CFFrame.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+CFFrame.h 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIView (CFFrame) 12 | 13 | @property (nonatomic, assign) CGFloat cf_x; 14 | @property (nonatomic, assign) CGFloat cf_y; 15 | @property (nonatomic, assign) CGFloat cf_centerX; 16 | @property (nonatomic, assign) CGFloat cf_centerY; 17 | @property (nonatomic, assign) CGFloat cf_width; 18 | @property (nonatomic, assign) CGFloat cf_height; 19 | 20 | @property (nonatomic, assign, readonly) CGFloat cf_maxX; 21 | @property (nonatomic, assign, readonly) CGFloat cf_maxY; 22 | 23 | @property (nonatomic, assign) CGPoint cf_origin; 24 | @property (nonatomic, assign) CGSize cf_size; 25 | 26 | + (instancetype)viewWithX:(CGFloat)x y:(CGFloat)y width:(CGFloat)width height:(CGFloat)height; 27 | + (instancetype)viewWithFrame:(CGRect)frame; 28 | + (instancetype)viewWithFrame:(CGRect)frame backgroundColor:(UIColor *)color; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /CFDropDownMenuView/CFDropDownMenuView/Lib/UIView+CFFrame.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+CFFrame.m 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // 8 | 9 | #import "UIView+CFFrame.h" 10 | 11 | @implementation UIView (CFFrame) 12 | 13 | //---------- X ----------// 14 | - (void)setCf_x:(CGFloat)cf_x { 15 | CGRect frame = self.frame; 16 | frame.origin.x = cf_x; 17 | self.frame = frame; 18 | } 19 | 20 | - (CGFloat)cf_x { 21 | return self.frame.origin.x; 22 | } 23 | 24 | //---------- Y ----------// 25 | - (void)setCf_y:(CGFloat)cf_y { 26 | CGRect frame = self.frame; 27 | frame.origin.y = cf_y; 28 | self.frame = frame; 29 | } 30 | 31 | - (CGFloat)cf_y { 32 | return self.frame.origin.y; 33 | } 34 | 35 | //---------- CenterX ----------// 36 | - (void)setCf_centerX:(CGFloat)centerX { 37 | CGPoint center = self.center; 38 | center.x = centerX; 39 | self.center = center; 40 | } 41 | 42 | - (CGFloat)cf_centerX { 43 | return self.center.x; 44 | } 45 | 46 | //---------- CenterY ----------// 47 | - (void)setCf_centerY:(CGFloat)centerY { 48 | CGPoint center = self.center; 49 | center.y = centerY; 50 | self.center = center; 51 | } 52 | 53 | - (CGFloat)cf_centerY { 54 | return self.center.y; 55 | } 56 | 57 | //---------- Width ----------// 58 | - (void)setCf_width:(CGFloat)width { 59 | CGRect frame = self.frame; 60 | frame.size.width = width; 61 | self.frame = frame; 62 | } 63 | 64 | - (CGFloat)cf_width { 65 | return self.frame.size.width; 66 | } 67 | 68 | //---------- Height ----------// 69 | - (void)setCf_height:(CGFloat)height { 70 | CGRect frame = self.frame; 71 | frame.size.height = height; 72 | self.frame = frame; 73 | } 74 | 75 | - (CGFloat)cf_height { 76 | return self.frame.size.height; 77 | } 78 | 79 | //---------- Origin ----------// 80 | - (void)setCf_origin:(CGPoint)origin { 81 | CGRect frame = self.frame; 82 | frame.origin = origin; 83 | self.frame = frame; 84 | } 85 | 86 | - (CGPoint)cf_origin { 87 | return self.frame.origin; 88 | } 89 | 90 | //---------- Size ----------// 91 | - (void)setCf_size:(CGSize)size { 92 | CGRect frame = self.frame; 93 | frame.size = size; 94 | self.frame = frame; 95 | } 96 | 97 | - (CGSize)cf_size { 98 | return self.frame.size; 99 | } 100 | 101 | - (CGFloat)cf_maxX { 102 | return self.frame.size.width + self.frame.origin.x; 103 | } 104 | 105 | - (CGFloat)cf_maxY { 106 | return self.frame.size.height + self.frame.origin.y; 107 | } 108 | 109 | 110 | + (instancetype)viewWithX:(CGFloat)x y:(CGFloat)y width:(CGFloat)width height:(CGFloat)height 111 | { 112 | return [[self alloc] initWithFrame:CGRectMake(x, y, width, height)]; 113 | } 114 | 115 | + (instancetype)viewWithFrame:(CGRect)frame 116 | { 117 | return [[UIView alloc] initWithFrame:frame]; 118 | } 119 | 120 | + (instancetype)viewWithFrame:(CGRect)frame backgroundColor:(UIColor *)color 121 | { 122 | UIView *view = [self viewWithFrame:frame]; 123 | view.backgroundColor = color; 124 | return view; 125 | } 126 | 127 | @end 128 | -------------------------------------------------------------------------------- /CFDropDownMenuView/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 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /CFDropDownMenuView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // DEMO 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /CFDropDownMenuView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. All rights reserved. 7 | // DEMO 8 | 9 | #import "ViewController.h" 10 | #import "CFDropDownMenuView.h" 11 | #import "CFMacro.h" 12 | #import "UIView+CFFrame.h" 13 | 14 | @interface ViewController () 15 | /* 展示结果tableView */ 16 | @property (nonatomic, strong) UITableView *showTableView; 17 | /* CFDropDownMenuView */ 18 | @property (nonatomic, strong) CFDropDownMenuView *dropDownMenuView; 19 | 20 | /* 展示结果的 假数据源 */ 21 | @property (nonatomic, strong) NSMutableArray *dataSourceArr; 22 | /* 所有的 假数据源 */ 23 | @property (nonatomic, strong) NSMutableArray *allDataSourceArr; 24 | @end 25 | 26 | @implementation ViewController 27 | 28 | - (void)viewDidLoad { 29 | [super viewDidLoad]; 30 | self.automaticallyAdjustsScrollViewInsets = NO; 31 | 32 | // 配置展示结果talbeview 33 | [self.view addSubview:self.showTableView]; 34 | 35 | UILabel *titleL = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, CFScreenWidth, 88)]; 36 | titleL.textAlignment = NSTextAlignmentCenter; 37 | titleL.backgroundColor = CFRandomColor; 38 | titleL.numberOfLines = 0; 39 | titleL.text = @"CFDropDownMenuView 展示demo\n交流QQ 545486205"; 40 | [self.view addSubview:titleL]; 41 | 42 | // 配置CFDropDownMenuView 43 | [self.view addSubview:self.dropDownMenuView]; 44 | 45 | 46 | } 47 | 48 | #pragma mark - lazy 49 | /* 配置CFDropDownMenuView */ 50 | - (CFDropDownMenuView *)dropDownMenuView 51 | { 52 | // DEMO 53 | _dropDownMenuView = [[CFDropDownMenuView alloc] initWithFrame:CGRectMake(0, 104, CFScreenWidth, 45)]; 54 | 55 | /** 56 | * stateConfigDict 属性 格式 详见CFDropDownMenuView.h文件 57 | */ 58 | // _dropDownMenuView.stateConfigDict = @{ 59 | // @"selected" : @[[UIColor redColor], @"红箭头"], 60 | // }; 61 | // _dropDownMenuView.stateConfigDict = @{ 62 | // @"normal" : @[[UIColor orangeColor], @"测试黄"], 63 | // }; 64 | // _dropDownMenuView.stateConfigDict = @{ 65 | // @"selected" : @[CF_Color_DefaultColor, @"天蓝箭头"], 66 | // @"normal" : @[[UIColor orangeColor], @"橙箭头"] 67 | // }; 68 | // 注: 需先 赋值数据源dataSourceArr二维数组 再赋值defaulTitleArray一维数组 69 | _dropDownMenuView.dataSourceArr = @[ 70 | // @[@"全部", @"iOS开发", @"安卓开发", @"JAVA开发", @"PHP开发",@"a",@"b",@"c",@"d",@"e",@"f",@"g",@"h",@"i",@"j",@"k",@"l",@"m"], 71 | @[@"全部", @"iOS开发", @"安卓开发", @"JAVA开发", @"PHP开发"], 72 | @[@"5-10k", @"10-15k", @"15-20k", @"20k以上"], 73 | @[@"1年以内", @"1-3年", @"3-5年", @"5年以上"] 74 | ].mutableCopy; 75 | 76 | _dropDownMenuView.defaulTitleArray = [NSArray arrayWithObjects:@"工作岗位",@"薪资", @"工作经验", nil]; 77 | 78 | _dropDownMenuView.delegate = self; 79 | 80 | // 下拉列表 起始y 81 | _dropDownMenuView.startY = CGRectGetMaxY(_dropDownMenuView.frame); 82 | 83 | /** 84 | * 回调方式一: block 85 | */ 86 | __weak typeof(self) weakSelf = self; 87 | _dropDownMenuView.chooseConditionBlock = ^(NSString *currentTitle, NSArray *currentTitleArray){ 88 | /** 89 | 实际开发情况 --- 仅需要拿到currentTitle / currentTitleArray 作为参数 向服务器请求数据即可 90 | */ 91 | NSMutableString *totalTitleStr = [[NSMutableString alloc] init]; 92 | NSMutableString *totalStr = [[NSMutableString alloc] init]; 93 | for (NSInteger i = 0; i < currentTitleArray.count; i++) { 94 | if (!([currentTitleArray[i] isEqualToString:@"工作岗位"] 95 | || [currentTitleArray[i] isEqualToString:@"薪资"] || [currentTitleArray[i] isEqualToString:@"工作经验"])) { 96 | [totalStr appendString:currentTitleArray[i]]; 97 | } 98 | 99 | if (0 == i) { 100 | [totalTitleStr appendString:@"("]; 101 | } 102 | [totalTitleStr appendString:currentTitleArray[i]]; 103 | if (i == currentTitleArray.count-1) { 104 | [totalTitleStr appendString:@")"]; 105 | break ; 106 | } 107 | [totalTitleStr appendString:@"---"]; 108 | 109 | } 110 | UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"职位筛选信息" message:[NSString stringWithFormat:@"您当前选中的是\n(%@)\n 当前所有展示的是\n%@", currentTitle, totalTitleStr] preferredStyle:UIAlertControllerStyleAlert]; 111 | UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 112 | // 匹配数据源 113 | NSString *totalString = totalStr; 114 | // 如果筛选条件包含全部, 则截取掉 115 | if ([totalStr containsString:@"全部"]) { 116 | totalString = [totalStr stringByReplacingOccurrencesOfString:@"全部" withString:@""]; 117 | } 118 | NSLog(@"totalString %@", totalString); 119 | if (totalString.length != 0) { // 条件 只是 全部 120 | NSArray *allDataSourceArr = weakSelf.allDataSourceArr; 121 | NSMutableArray *tempArr = [[NSMutableArray alloc] init]; 122 | for (NSInteger i = 0; i < allDataSourceArr.count; i++) { 123 | NSString *str = allDataSourceArr[i]; 124 | str = [str stringByReplacingOccurrencesOfString:@" " withString:@""]; 125 | 126 | if ([str containsString:totalString]) { 127 | [tempArr addObject:allDataSourceArr[i]]; 128 | } 129 | } 130 | // 赋值筛选后的数据源 131 | weakSelf.dataSourceArr = tempArr; 132 | NSLog(@"筛选后数据源 %@", weakSelf.dataSourceArr); 133 | 134 | // 重新刷新表格 -- 显示刷新后的数据 135 | [weakSelf.showTableView reloadData]; 136 | } 137 | 138 | 139 | UIAlertController *alertController2 = [UIAlertController alertControllerWithTitle:@"" message:[NSString stringWithFormat:@"共有 %zd 条结果", weakSelf.dataSourceArr.count] preferredStyle:UIAlertControllerStyleAlert]; 140 | [weakSelf presentViewController:alertController2 animated:NO completion:^{ 141 | UIAlertAction *alertAction2 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { 142 | }]; 143 | [alertController2 addAction:alertAction2]; 144 | }]; 145 | 146 | }]; 147 | [alertController addAction:alertAction]; 148 | [weakSelf presentViewController:alertController animated:NO completion:^{ 149 | }]; 150 | }; 151 | 152 | 153 | return _dropDownMenuView; 154 | 155 | } 156 | 157 | /* 展示结果showTableView */ 158 | - (UITableView *)showTableView 159 | { 160 | if (!_showTableView) { 161 | _showTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 110, CFScreenWidth, CFScreenHeight) style:UITableViewStyleGrouped]; 162 | _showTableView.contentInset = UIEdgeInsetsMake(0, 0, 130, 0); 163 | _showTableView.scrollIndicatorInsets = UIEdgeInsetsMake(self.dropDownMenuView.cf_height, 0, _showTableView.cf_y, 0); 164 | _showTableView.delegate = self; 165 | _showTableView.dataSource = self; 166 | _showTableView.backgroundColor = CF_Color_DefalutBackGroundColor; 167 | 168 | // 配置假数据源 169 | NSMutableArray *dataSourceArr = @[].mutableCopy; 170 | for (NSInteger i = 0; i < 3; i++) { 171 | NSString *iOS = @"iOS开发 5-10k 1年以内"; 172 | NSString *android = @"安卓开发 5-10k 1年以内"; 173 | NSString *JAVA = @"JAVA开发 5-10k 1年以内"; 174 | NSString *PHP = @"PHP开发 5-10k 1年以内"; 175 | [dataSourceArr addObject:iOS]; 176 | [dataSourceArr addObject:android]; 177 | [dataSourceArr addObject:JAVA]; 178 | [dataSourceArr addObject:PHP]; 179 | } 180 | for (NSInteger i = 0; i < 3; i++) { 181 | NSString *iOS = @"iOS开发 5-10k 1-3年"; 182 | NSString *android = @"安卓开发 5-10k 1-3年"; 183 | NSString *JAVA = @"JAVA开发 5-10k 1-3年"; 184 | NSString *PHP = @"PHP开发 5-10k 1-3年"; 185 | [dataSourceArr addObject:iOS]; 186 | [dataSourceArr addObject:android]; 187 | [dataSourceArr addObject:JAVA]; 188 | [dataSourceArr addObject:PHP]; 189 | } 190 | for (NSInteger i = 0; i < 2; i++) { 191 | NSString *JAVA = @"JAVA开发 10-15k 1年以内"; 192 | NSString *PHP = @"PHP开发 10-15k 1年以内"; 193 | [dataSourceArr addObject:JAVA]; 194 | [dataSourceArr addObject:PHP]; 195 | } 196 | for (NSInteger i = 0; i < 2; i++) { 197 | NSString *iOS = @"iOS开发 10-15k 1-3年"; 198 | NSString *android = @"安卓开发 10-15k 1-3年"; 199 | NSString *JAVA = @"JAVA开发 10-15k 1-3年"; 200 | NSString *PHP = @"PHP开发 10-15k 1-3年"; 201 | [dataSourceArr addObject:iOS]; 202 | [dataSourceArr addObject:android]; 203 | [dataSourceArr addObject:JAVA]; 204 | [dataSourceArr addObject:PHP]; 205 | } 206 | for (NSInteger i = 0; i < 2; i++) { 207 | NSString *iOS = @"iOS开发 10-15k 3-5年"; 208 | NSString *android = @"安卓开发 10-15k 3-5年"; 209 | NSString *JAVA = @"JAVA开发 10-15k 3-5年"; 210 | NSString *PHP = @"PHP开发 10-15k 3-5年"; 211 | [dataSourceArr addObject:iOS]; 212 | [dataSourceArr addObject:android]; 213 | [dataSourceArr addObject:JAVA]; 214 | [dataSourceArr addObject:PHP]; 215 | } 216 | for (NSInteger i = 0; i < 2; i++) { 217 | NSString *JAVA = @"JAVA开发 10-15k 5年以上"; 218 | NSString *PHP = @"PHP开发 10-15k 5年以上"; 219 | [dataSourceArr addObject:JAVA]; 220 | [dataSourceArr addObject:PHP]; 221 | } 222 | for (NSInteger i = 0; i < 3; i++) { 223 | NSString *iOS = @"iOS开发 15-20k 1-3年"; 224 | NSString *android = @"安卓开发 15-20k 1-3年"; 225 | NSString *JAVA = @"JAVA开发 15-20k 1-3年"; 226 | NSString *PHP = @"PHP开发 15-20k 1-3年"; 227 | [dataSourceArr addObject:iOS]; 228 | [dataSourceArr addObject:android]; 229 | [dataSourceArr addObject:JAVA]; 230 | [dataSourceArr addObject:PHP]; 231 | } 232 | for (NSInteger i = 0; i < 2; i++) { 233 | NSString *iOS = @"iOS开发 15-20k 3-5年"; 234 | NSString *android = @"安卓开发 15-20k 3-5年"; 235 | NSString *JAVA = @"JAVA开发 15-20k 5年以上"; 236 | NSString *PHP = @"PHP开发 15-20k 5年以上"; 237 | [dataSourceArr addObject:iOS]; 238 | [dataSourceArr addObject:android]; 239 | [dataSourceArr addObject:JAVA]; 240 | [dataSourceArr addObject:PHP]; 241 | } 242 | for (NSInteger i = 0; i < 2; i++) { 243 | NSString *iOS = @"iOS开发 20k以上 3-5年"; 244 | NSString *android = @"安卓开发 20k以上 3-5年"; 245 | NSString *JAVA = @"JAVA开发 20k以上 5年以上"; 246 | NSString *PHP = @"PHP开发 20k以上 5年以上"; 247 | [dataSourceArr addObject:iOS]; 248 | [dataSourceArr addObject:android]; 249 | [dataSourceArr addObject:JAVA]; 250 | [dataSourceArr addObject:PHP]; 251 | } 252 | for (NSInteger i = 0; i < 3; i++) { 253 | NSString *iOS = @"iOS开发 20k以上 5年以上"; 254 | NSString *android = @"安卓开发 20k以上 5年以上"; 255 | [dataSourceArr addObject:iOS]; 256 | [dataSourceArr addObject:android]; 257 | 258 | } 259 | _dataSourceArr = dataSourceArr; 260 | _allDataSourceArr = dataSourceArr; 261 | } 262 | return _showTableView; 263 | } 264 | 265 | #pragma mark - UITableViewDelegate/UITableViewDataSource 266 | - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 267 | { 268 | return 45; 269 | } 270 | 271 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 272 | { 273 | return self.dataSourceArr.count; 274 | } 275 | 276 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 277 | { 278 | static NSString *cellID = @"cellID"; 279 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; 280 | if (!cell) { 281 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID]; 282 | } 283 | NSString *str = self.dataSourceArr[indexPath.row]; 284 | NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:str]; 285 | [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0, 6)]; 286 | [attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(6, 8)]; 287 | 288 | cell.textLabel.attributedText = attributedString; 289 | 290 | 291 | 292 | return cell; 293 | } 294 | 295 | - (void)didReceiveMemoryWarning { 296 | [super didReceiveMemoryWarning]; 297 | // Dispose of any resources that can be recreated. 298 | } 299 | 300 | @end 301 | -------------------------------------------------------------------------------- /CFDropDownMenuView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CFDropDownMenuView 4 | // 5 | // Created by Peak on 16/5/28. 6 | // Copyright © 2016年 陈峰. 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 CoderPeak (https://github.com/CoderPeak/CFDropDownMenuView) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CFDropDownMenuView (交流QQ 545486205) 2 | ### 简单好用的, 可自定义选中和非选中状态样式的 下拉列表菜单选择筛选条件的控件 3 | 4 | ##### 支持pod导入 5 | ##### pod 'CFDropDownMenuView' 6 | 7 | ### demo展示 - 由于网络原因, 可能gif效果图会展示的比较卡, 可以下载运行查看demo---简单使用代码在gif图片下面 8 | ### 特别注意 9 | - 用cocoapods导入使用的时候, 项目没任何问题 10 | - 但是仅在下载demo的时候 .bundle资源包实际上已经下载到您本地 但是不知为何, 用xcode打开项目的时候 xcode不能识别.bundle资源包. 右击项目文件 show in finder 即可以查看到.bundle资源包 然后手动拖入xcode即可 此时箭头就会随下拉列表的展示/缩回 进行旋转动画 11 | ![](/showdemo.gif) 12 | ### 使用 13 | - 创建 14 | 15 | ``` 16 | // 创建 17 | CFDropDownMenuView *dropDownMenuView = [[CFDropDownMenuView alloc] initWithFrame:CGRectMake(0, 104, [UIScreen mainScreen].bounds.size.width, 45)]; 18 | 19 | /** 20 | * stateConfigDict 属性 格式 详见CFDropDownMenuView.h文件 21 | * 可不传 使用默认样式 / 也可自定义样式 22 | */ 23 | // dropDownMenuView.stateConfigDict = @{ 24 | // @"selected" : @[[UIColor redColor], @"红箭头"], 25 | // }; 26 | // dropDownMenuView.stateConfigDict = @{ 27 | // @"normal" : @[[UIColor orangeColor], @"测试黄"], 28 | // }; 29 | // dropDownMenuView.stateConfigDict = @{ 30 | // @"selected" : @[CF_Color_DefaultColor, @"天蓝箭头"], 31 | // @"normal" : @[[UIColor orangeColor], @"橙箭头"] 32 | // }; }; 33 | // 注: 需先 赋值数据源dataSourceArr二维数组 再赋值defaulTitleArray一维数组 34 | dropDownMenuView.dataSourceArr = @[ 35 | @[@"全部", @"iOS开发", @"安卓开发", @"JAVA开发", @"PHP开发"], 36 | @[@"5-10k", @"10-15k", @"15-20k", @"20k以上"], 37 | @[@"1年以内", @"1-3年", @"3-5年", @"5年以上"] 38 | ].mutableCopy; 39 | 40 | dropDownMenuView.defaulTitleArray = [NSArray arrayWithObjects:@"工作岗位",@"薪资", @"工作经验", nil]; 41 | // 设置代理 42 | dropDownMenuView.delegate = self; 43 | 44 | // 下拉列表 起始y 45 | dropDownMenuView.startY = CGRectGetMaxY(dropDownMenuView.frame); 46 | 47 | /** 48 | * 回调方式一: block 49 | */ 50 | __weak typeof(self) weakSelf = self; 51 | dropDownMenuView.chooseConditionBlock = ^(NSString *currentTitle, NSArray *currentTitleArray){ 52 | NSLog(@"当前选中的是%@ 展示的所有条件是%@", currentTitle, currentTitleArray); 53 | }; 54 | // 添加到父视图中 55 | [self.view addSubview:dropDownMenuView]; 56 | ``` 57 | 58 | ``` 59 | /** 60 | * 回调方式二: 代理 61 | */ 62 | - (void)dropDownMenuView:(CFDropDownMenuView *)dropDownMenuView clickOnCurrentButtonWithTitle:(NSString *)currentTitle andCurrentTitleArray:(NSArray *)currentTitleArray{ 63 | NSLog(@"当前选中的是%@ 展示的所有条件是%@", currentTitle, currentTitleArray); 64 | } 65 | 66 | ``` 67 | -------------------------------------------------------------------------------- /showdemo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoderPeak/CFDropDownMenuView/e0fc532fb21e8f329ab83adb1b228208a2641a89/showdemo.gif --------------------------------------------------------------------------------