├── .gitignore ├── DLPickerView.podspec ├── DLPickerView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── DLPickerView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── DLPickerView │ ├── DLPickerView.h │ └── DLPickerView.m ├── Info.plist ├── Time.plist ├── ViewController.h ├── ViewController.m └── main.m ├── DLPickerViewTests ├── DLPickerViewTests.m └── Info.plist ├── DLPickerViewUITests ├── DLPickerViewUITests.m └── Info.plist ├── LICENSE ├── README.md └── screenshots ├── Simulator1.png ├── Simulator2.png ├── Simulator3.png └── Simulator4.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 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 | -------------------------------------------------------------------------------- /DLPickerView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | # 名称 使用的时候pod search [name] 4 | s.name = 'DLPickerView' 5 | # 代码库的版本 6 | s.version = '1.0.1' 7 | # 简介 8 | s.summary = "iOS开发常用的数据选择器" 9 | # 主页 10 | s.homepage = 'https://github.com/coder-zwz/DLPickerView' 11 | # 许可证书类型,要和仓库的LICENSE 的类型一致 12 | s.license = { :type => 'MIT', :file => 'LICENSE' } 13 | # 作者名称 和 邮箱 14 | s.author = {"zuweizhong" => "2416086440@qq.com" } 15 | # 代码的Clone 地址 和 tag 版本 16 | s.source = { :git => 'https://github.com/coder-zwz/DLPickerView.git', :tag => s.version.to_s } 17 | 18 | s.ios.deployment_target = '8.0' 19 | # 如果使用pod 需要导入哪些资源 20 | s.source_files = 'DLPickerView/DLPickerView/**/*' 21 | s.frameworks = 'Foundation', 'StoreKit' 22 | # 框架是否使用的ARC 23 | s.requires_arc = true 24 | 25 | end 26 | -------------------------------------------------------------------------------- /DLPickerView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0F5DBC181DDE9B4F001CC4B4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5DBC171DDE9B4F001CC4B4 /* main.m */; }; 11 | 0F5DBC1B1DDE9B4F001CC4B4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5DBC1A1DDE9B4F001CC4B4 /* AppDelegate.m */; }; 12 | 0F5DBC1E1DDE9B4F001CC4B4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5DBC1D1DDE9B4F001CC4B4 /* ViewController.m */; }; 13 | 0F5DBC211DDE9B4F001CC4B4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F5DBC1F1DDE9B4F001CC4B4 /* Main.storyboard */; }; 14 | 0F5DBC231DDE9B4F001CC4B4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0F5DBC221DDE9B4F001CC4B4 /* Assets.xcassets */; }; 15 | 0F5DBC261DDE9B4F001CC4B4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0F5DBC241DDE9B4F001CC4B4 /* LaunchScreen.storyboard */; }; 16 | 0F5DBC311DDE9B4F001CC4B4 /* DLPickerViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5DBC301DDE9B4F001CC4B4 /* DLPickerViewTests.m */; }; 17 | 0F5DBC3C1DDE9B4F001CC4B4 /* DLPickerViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5DBC3B1DDE9B4F001CC4B4 /* DLPickerViewUITests.m */; }; 18 | 0F5DBC4C1DDE9B8B001CC4B4 /* DLPickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0F5DBC4B1DDE9B8B001CC4B4 /* DLPickerView.m */; }; 19 | 0F5DBC4E1DDE9BC7001CC4B4 /* Time.plist in Resources */ = {isa = PBXBuildFile; fileRef = 0F5DBC4D1DDE9BC7001CC4B4 /* Time.plist */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 0F5DBC2D1DDE9B4F001CC4B4 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 0F5DBC0B1DDE9B4F001CC4B4 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 0F5DBC121DDE9B4F001CC4B4; 28 | remoteInfo = DLPickerView; 29 | }; 30 | 0F5DBC381DDE9B4F001CC4B4 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 0F5DBC0B1DDE9B4F001CC4B4 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 0F5DBC121DDE9B4F001CC4B4; 35 | remoteInfo = DLPickerView; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 0F5DBC131DDE9B4F001CC4B4 /* DLPickerView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DLPickerView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 0F5DBC171DDE9B4F001CC4B4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 42 | 0F5DBC191DDE9B4F001CC4B4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 43 | 0F5DBC1A1DDE9B4F001CC4B4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 44 | 0F5DBC1C1DDE9B4F001CC4B4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 45 | 0F5DBC1D1DDE9B4F001CC4B4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 46 | 0F5DBC201DDE9B4F001CC4B4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 47 | 0F5DBC221DDE9B4F001CC4B4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | 0F5DBC251DDE9B4F001CC4B4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 49 | 0F5DBC271DDE9B4F001CC4B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | 0F5DBC2C1DDE9B4F001CC4B4 /* DLPickerViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DLPickerViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 0F5DBC301DDE9B4F001CC4B4 /* DLPickerViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DLPickerViewTests.m; sourceTree = ""; }; 52 | 0F5DBC321DDE9B4F001CC4B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | 0F5DBC371DDE9B4F001CC4B4 /* DLPickerViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DLPickerViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 0F5DBC3B1DDE9B4F001CC4B4 /* DLPickerViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DLPickerViewUITests.m; sourceTree = ""; }; 55 | 0F5DBC3D1DDE9B4F001CC4B4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 0F5DBC4A1DDE9B8B001CC4B4 /* DLPickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DLPickerView.h; sourceTree = ""; }; 57 | 0F5DBC4B1DDE9B8B001CC4B4 /* DLPickerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DLPickerView.m; sourceTree = ""; }; 58 | 0F5DBC4D1DDE9BC7001CC4B4 /* Time.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Time.plist; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | 0F5DBC101DDE9B4F001CC4B4 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | 0F5DBC291DDE9B4F001CC4B4 /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | 0F5DBC341DDE9B4F001CC4B4 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 0F5DBC0A1DDE9B4F001CC4B4 = { 87 | isa = PBXGroup; 88 | children = ( 89 | 0F5DBC151DDE9B4F001CC4B4 /* DLPickerView */, 90 | 0F5DBC2F1DDE9B4F001CC4B4 /* DLPickerViewTests */, 91 | 0F5DBC3A1DDE9B4F001CC4B4 /* DLPickerViewUITests */, 92 | 0F5DBC141DDE9B4F001CC4B4 /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 0F5DBC141DDE9B4F001CC4B4 /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 0F5DBC131DDE9B4F001CC4B4 /* DLPickerView.app */, 100 | 0F5DBC2C1DDE9B4F001CC4B4 /* DLPickerViewTests.xctest */, 101 | 0F5DBC371DDE9B4F001CC4B4 /* DLPickerViewUITests.xctest */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 0F5DBC151DDE9B4F001CC4B4 /* DLPickerView */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 0F5DBC491DDE9B8B001CC4B4 /* DLPickerView */, 110 | 0F5DBC191DDE9B4F001CC4B4 /* AppDelegate.h */, 111 | 0F5DBC1A1DDE9B4F001CC4B4 /* AppDelegate.m */, 112 | 0F5DBC1C1DDE9B4F001CC4B4 /* ViewController.h */, 113 | 0F5DBC1D1DDE9B4F001CC4B4 /* ViewController.m */, 114 | 0F5DBC1F1DDE9B4F001CC4B4 /* Main.storyboard */, 115 | 0F5DBC221DDE9B4F001CC4B4 /* Assets.xcassets */, 116 | 0F5DBC241DDE9B4F001CC4B4 /* LaunchScreen.storyboard */, 117 | 0F5DBC271DDE9B4F001CC4B4 /* Info.plist */, 118 | 0F5DBC161DDE9B4F001CC4B4 /* Supporting Files */, 119 | ); 120 | path = DLPickerView; 121 | sourceTree = ""; 122 | }; 123 | 0F5DBC161DDE9B4F001CC4B4 /* Supporting Files */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 0F5DBC4D1DDE9BC7001CC4B4 /* Time.plist */, 127 | 0F5DBC171DDE9B4F001CC4B4 /* main.m */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | 0F5DBC2F1DDE9B4F001CC4B4 /* DLPickerViewTests */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 0F5DBC301DDE9B4F001CC4B4 /* DLPickerViewTests.m */, 136 | 0F5DBC321DDE9B4F001CC4B4 /* Info.plist */, 137 | ); 138 | path = DLPickerViewTests; 139 | sourceTree = ""; 140 | }; 141 | 0F5DBC3A1DDE9B4F001CC4B4 /* DLPickerViewUITests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 0F5DBC3B1DDE9B4F001CC4B4 /* DLPickerViewUITests.m */, 145 | 0F5DBC3D1DDE9B4F001CC4B4 /* Info.plist */, 146 | ); 147 | path = DLPickerViewUITests; 148 | sourceTree = ""; 149 | }; 150 | 0F5DBC491DDE9B8B001CC4B4 /* DLPickerView */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 0F5DBC4A1DDE9B8B001CC4B4 /* DLPickerView.h */, 154 | 0F5DBC4B1DDE9B8B001CC4B4 /* DLPickerView.m */, 155 | ); 156 | path = DLPickerView; 157 | sourceTree = ""; 158 | }; 159 | /* End PBXGroup section */ 160 | 161 | /* Begin PBXNativeTarget section */ 162 | 0F5DBC121DDE9B4F001CC4B4 /* DLPickerView */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 0F5DBC401DDE9B4F001CC4B4 /* Build configuration list for PBXNativeTarget "DLPickerView" */; 165 | buildPhases = ( 166 | 0F5DBC0F1DDE9B4F001CC4B4 /* Sources */, 167 | 0F5DBC101DDE9B4F001CC4B4 /* Frameworks */, 168 | 0F5DBC111DDE9B4F001CC4B4 /* Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | ); 174 | name = DLPickerView; 175 | productName = DLPickerView; 176 | productReference = 0F5DBC131DDE9B4F001CC4B4 /* DLPickerView.app */; 177 | productType = "com.apple.product-type.application"; 178 | }; 179 | 0F5DBC2B1DDE9B4F001CC4B4 /* DLPickerViewTests */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = 0F5DBC431DDE9B4F001CC4B4 /* Build configuration list for PBXNativeTarget "DLPickerViewTests" */; 182 | buildPhases = ( 183 | 0F5DBC281DDE9B4F001CC4B4 /* Sources */, 184 | 0F5DBC291DDE9B4F001CC4B4 /* Frameworks */, 185 | 0F5DBC2A1DDE9B4F001CC4B4 /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | 0F5DBC2E1DDE9B4F001CC4B4 /* PBXTargetDependency */, 191 | ); 192 | name = DLPickerViewTests; 193 | productName = DLPickerViewTests; 194 | productReference = 0F5DBC2C1DDE9B4F001CC4B4 /* DLPickerViewTests.xctest */; 195 | productType = "com.apple.product-type.bundle.unit-test"; 196 | }; 197 | 0F5DBC361DDE9B4F001CC4B4 /* DLPickerViewUITests */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = 0F5DBC461DDE9B4F001CC4B4 /* Build configuration list for PBXNativeTarget "DLPickerViewUITests" */; 200 | buildPhases = ( 201 | 0F5DBC331DDE9B4F001CC4B4 /* Sources */, 202 | 0F5DBC341DDE9B4F001CC4B4 /* Frameworks */, 203 | 0F5DBC351DDE9B4F001CC4B4 /* Resources */, 204 | ); 205 | buildRules = ( 206 | ); 207 | dependencies = ( 208 | 0F5DBC391DDE9B4F001CC4B4 /* PBXTargetDependency */, 209 | ); 210 | name = DLPickerViewUITests; 211 | productName = DLPickerViewUITests; 212 | productReference = 0F5DBC371DDE9B4F001CC4B4 /* DLPickerViewUITests.xctest */; 213 | productType = "com.apple.product-type.bundle.ui-testing"; 214 | }; 215 | /* End PBXNativeTarget section */ 216 | 217 | /* Begin PBXProject section */ 218 | 0F5DBC0B1DDE9B4F001CC4B4 /* Project object */ = { 219 | isa = PBXProject; 220 | attributes = { 221 | LastUpgradeCheck = 0810; 222 | ORGANIZATIONNAME = zuweizhong; 223 | TargetAttributes = { 224 | 0F5DBC121DDE9B4F001CC4B4 = { 225 | CreatedOnToolsVersion = 8.1; 226 | ProvisioningStyle = Automatic; 227 | }; 228 | 0F5DBC2B1DDE9B4F001CC4B4 = { 229 | CreatedOnToolsVersion = 8.1; 230 | ProvisioningStyle = Automatic; 231 | TestTargetID = 0F5DBC121DDE9B4F001CC4B4; 232 | }; 233 | 0F5DBC361DDE9B4F001CC4B4 = { 234 | CreatedOnToolsVersion = 8.1; 235 | ProvisioningStyle = Automatic; 236 | TestTargetID = 0F5DBC121DDE9B4F001CC4B4; 237 | }; 238 | }; 239 | }; 240 | buildConfigurationList = 0F5DBC0E1DDE9B4F001CC4B4 /* Build configuration list for PBXProject "DLPickerView" */; 241 | compatibilityVersion = "Xcode 3.2"; 242 | developmentRegion = English; 243 | hasScannedForEncodings = 0; 244 | knownRegions = ( 245 | en, 246 | Base, 247 | ); 248 | mainGroup = 0F5DBC0A1DDE9B4F001CC4B4; 249 | productRefGroup = 0F5DBC141DDE9B4F001CC4B4 /* Products */; 250 | projectDirPath = ""; 251 | projectRoot = ""; 252 | targets = ( 253 | 0F5DBC121DDE9B4F001CC4B4 /* DLPickerView */, 254 | 0F5DBC2B1DDE9B4F001CC4B4 /* DLPickerViewTests */, 255 | 0F5DBC361DDE9B4F001CC4B4 /* DLPickerViewUITests */, 256 | ); 257 | }; 258 | /* End PBXProject section */ 259 | 260 | /* Begin PBXResourcesBuildPhase section */ 261 | 0F5DBC111DDE9B4F001CC4B4 /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | 0F5DBC261DDE9B4F001CC4B4 /* LaunchScreen.storyboard in Resources */, 266 | 0F5DBC231DDE9B4F001CC4B4 /* Assets.xcassets in Resources */, 267 | 0F5DBC211DDE9B4F001CC4B4 /* Main.storyboard in Resources */, 268 | 0F5DBC4E1DDE9BC7001CC4B4 /* Time.plist in Resources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | 0F5DBC2A1DDE9B4F001CC4B4 /* Resources */ = { 273 | isa = PBXResourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | 0F5DBC351DDE9B4F001CC4B4 /* Resources */ = { 280 | isa = PBXResourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | /* End PBXResourcesBuildPhase section */ 287 | 288 | /* Begin PBXSourcesBuildPhase section */ 289 | 0F5DBC0F1DDE9B4F001CC4B4 /* Sources */ = { 290 | isa = PBXSourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | 0F5DBC1E1DDE9B4F001CC4B4 /* ViewController.m in Sources */, 294 | 0F5DBC1B1DDE9B4F001CC4B4 /* AppDelegate.m in Sources */, 295 | 0F5DBC4C1DDE9B8B001CC4B4 /* DLPickerView.m in Sources */, 296 | 0F5DBC181DDE9B4F001CC4B4 /* main.m in Sources */, 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | 0F5DBC281DDE9B4F001CC4B4 /* Sources */ = { 301 | isa = PBXSourcesBuildPhase; 302 | buildActionMask = 2147483647; 303 | files = ( 304 | 0F5DBC311DDE9B4F001CC4B4 /* DLPickerViewTests.m in Sources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | 0F5DBC331DDE9B4F001CC4B4 /* Sources */ = { 309 | isa = PBXSourcesBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | 0F5DBC3C1DDE9B4F001CC4B4 /* DLPickerViewUITests.m in Sources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | /* End PBXSourcesBuildPhase section */ 317 | 318 | /* Begin PBXTargetDependency section */ 319 | 0F5DBC2E1DDE9B4F001CC4B4 /* PBXTargetDependency */ = { 320 | isa = PBXTargetDependency; 321 | target = 0F5DBC121DDE9B4F001CC4B4 /* DLPickerView */; 322 | targetProxy = 0F5DBC2D1DDE9B4F001CC4B4 /* PBXContainerItemProxy */; 323 | }; 324 | 0F5DBC391DDE9B4F001CC4B4 /* PBXTargetDependency */ = { 325 | isa = PBXTargetDependency; 326 | target = 0F5DBC121DDE9B4F001CC4B4 /* DLPickerView */; 327 | targetProxy = 0F5DBC381DDE9B4F001CC4B4 /* PBXContainerItemProxy */; 328 | }; 329 | /* End PBXTargetDependency section */ 330 | 331 | /* Begin PBXVariantGroup section */ 332 | 0F5DBC1F1DDE9B4F001CC4B4 /* Main.storyboard */ = { 333 | isa = PBXVariantGroup; 334 | children = ( 335 | 0F5DBC201DDE9B4F001CC4B4 /* Base */, 336 | ); 337 | name = Main.storyboard; 338 | sourceTree = ""; 339 | }; 340 | 0F5DBC241DDE9B4F001CC4B4 /* LaunchScreen.storyboard */ = { 341 | isa = PBXVariantGroup; 342 | children = ( 343 | 0F5DBC251DDE9B4F001CC4B4 /* Base */, 344 | ); 345 | name = LaunchScreen.storyboard; 346 | sourceTree = ""; 347 | }; 348 | /* End PBXVariantGroup section */ 349 | 350 | /* Begin XCBuildConfiguration section */ 351 | 0F5DBC3E1DDE9B4F001CC4B4 /* Debug */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ALWAYS_SEARCH_USER_PATHS = NO; 355 | CLANG_ANALYZER_NONNULL = YES; 356 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 357 | CLANG_CXX_LIBRARY = "libc++"; 358 | CLANG_ENABLE_MODULES = YES; 359 | CLANG_ENABLE_OBJC_ARC = YES; 360 | CLANG_WARN_BOOL_CONVERSION = YES; 361 | CLANG_WARN_CONSTANT_CONVERSION = YES; 362 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 363 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 364 | CLANG_WARN_EMPTY_BODY = YES; 365 | CLANG_WARN_ENUM_CONVERSION = YES; 366 | CLANG_WARN_INFINITE_RECURSION = YES; 367 | CLANG_WARN_INT_CONVERSION = YES; 368 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 369 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 370 | CLANG_WARN_UNREACHABLE_CODE = YES; 371 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 372 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 373 | COPY_PHASE_STRIP = NO; 374 | DEBUG_INFORMATION_FORMAT = dwarf; 375 | ENABLE_STRICT_OBJC_MSGSEND = YES; 376 | ENABLE_TESTABILITY = YES; 377 | GCC_C_LANGUAGE_STANDARD = gnu99; 378 | GCC_DYNAMIC_NO_PIC = NO; 379 | GCC_NO_COMMON_BLOCKS = YES; 380 | GCC_OPTIMIZATION_LEVEL = 0; 381 | GCC_PREPROCESSOR_DEFINITIONS = ( 382 | "DEBUG=1", 383 | "$(inherited)", 384 | ); 385 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 386 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 387 | GCC_WARN_UNDECLARED_SELECTOR = YES; 388 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 389 | GCC_WARN_UNUSED_FUNCTION = YES; 390 | GCC_WARN_UNUSED_VARIABLE = YES; 391 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 392 | MTL_ENABLE_DEBUG_INFO = YES; 393 | ONLY_ACTIVE_ARCH = YES; 394 | SDKROOT = iphoneos; 395 | TARGETED_DEVICE_FAMILY = "1,2"; 396 | }; 397 | name = Debug; 398 | }; 399 | 0F5DBC3F1DDE9B4F001CC4B4 /* Release */ = { 400 | isa = XCBuildConfiguration; 401 | buildSettings = { 402 | ALWAYS_SEARCH_USER_PATHS = NO; 403 | CLANG_ANALYZER_NONNULL = YES; 404 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 405 | CLANG_CXX_LIBRARY = "libc++"; 406 | CLANG_ENABLE_MODULES = YES; 407 | CLANG_ENABLE_OBJC_ARC = YES; 408 | CLANG_WARN_BOOL_CONVERSION = YES; 409 | CLANG_WARN_CONSTANT_CONVERSION = YES; 410 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 411 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 412 | CLANG_WARN_EMPTY_BODY = YES; 413 | CLANG_WARN_ENUM_CONVERSION = YES; 414 | CLANG_WARN_INFINITE_RECURSION = YES; 415 | CLANG_WARN_INT_CONVERSION = YES; 416 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 417 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 418 | CLANG_WARN_UNREACHABLE_CODE = YES; 419 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 420 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 421 | COPY_PHASE_STRIP = NO; 422 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 423 | ENABLE_NS_ASSERTIONS = NO; 424 | ENABLE_STRICT_OBJC_MSGSEND = YES; 425 | GCC_C_LANGUAGE_STANDARD = gnu99; 426 | GCC_NO_COMMON_BLOCKS = YES; 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 = 10.1; 434 | MTL_ENABLE_DEBUG_INFO = NO; 435 | SDKROOT = iphoneos; 436 | TARGETED_DEVICE_FAMILY = "1,2"; 437 | VALIDATE_PRODUCT = YES; 438 | }; 439 | name = Release; 440 | }; 441 | 0F5DBC411DDE9B4F001CC4B4 /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 445 | INFOPLIST_FILE = DLPickerView/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 447 | PRODUCT_BUNDLE_IDENTIFIER = visoft.DLPickerView; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | }; 450 | name = Debug; 451 | }; 452 | 0F5DBC421DDE9B4F001CC4B4 /* Release */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | INFOPLIST_FILE = DLPickerView/Info.plist; 457 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 458 | PRODUCT_BUNDLE_IDENTIFIER = visoft.DLPickerView; 459 | PRODUCT_NAME = "$(TARGET_NAME)"; 460 | }; 461 | name = Release; 462 | }; 463 | 0F5DBC441DDE9B4F001CC4B4 /* Debug */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | BUNDLE_LOADER = "$(TEST_HOST)"; 467 | INFOPLIST_FILE = DLPickerViewTests/Info.plist; 468 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 469 | PRODUCT_BUNDLE_IDENTIFIER = visoft.DLPickerViewTests; 470 | PRODUCT_NAME = "$(TARGET_NAME)"; 471 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DLPickerView.app/DLPickerView"; 472 | }; 473 | name = Debug; 474 | }; 475 | 0F5DBC451DDE9B4F001CC4B4 /* Release */ = { 476 | isa = XCBuildConfiguration; 477 | buildSettings = { 478 | BUNDLE_LOADER = "$(TEST_HOST)"; 479 | INFOPLIST_FILE = DLPickerViewTests/Info.plist; 480 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 481 | PRODUCT_BUNDLE_IDENTIFIER = visoft.DLPickerViewTests; 482 | PRODUCT_NAME = "$(TARGET_NAME)"; 483 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DLPickerView.app/DLPickerView"; 484 | }; 485 | name = Release; 486 | }; 487 | 0F5DBC471DDE9B4F001CC4B4 /* Debug */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | INFOPLIST_FILE = DLPickerViewUITests/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = visoft.DLPickerViewUITests; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | TEST_TARGET_NAME = DLPickerView; 495 | }; 496 | name = Debug; 497 | }; 498 | 0F5DBC481DDE9B4F001CC4B4 /* Release */ = { 499 | isa = XCBuildConfiguration; 500 | buildSettings = { 501 | INFOPLIST_FILE = DLPickerViewUITests/Info.plist; 502 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 503 | PRODUCT_BUNDLE_IDENTIFIER = visoft.DLPickerViewUITests; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | TEST_TARGET_NAME = DLPickerView; 506 | }; 507 | name = Release; 508 | }; 509 | /* End XCBuildConfiguration section */ 510 | 511 | /* Begin XCConfigurationList section */ 512 | 0F5DBC0E1DDE9B4F001CC4B4 /* Build configuration list for PBXProject "DLPickerView" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | 0F5DBC3E1DDE9B4F001CC4B4 /* Debug */, 516 | 0F5DBC3F1DDE9B4F001CC4B4 /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | defaultConfigurationName = Release; 520 | }; 521 | 0F5DBC401DDE9B4F001CC4B4 /* Build configuration list for PBXNativeTarget "DLPickerView" */ = { 522 | isa = XCConfigurationList; 523 | buildConfigurations = ( 524 | 0F5DBC411DDE9B4F001CC4B4 /* Debug */, 525 | 0F5DBC421DDE9B4F001CC4B4 /* Release */, 526 | ); 527 | defaultConfigurationIsVisible = 0; 528 | }; 529 | 0F5DBC431DDE9B4F001CC4B4 /* Build configuration list for PBXNativeTarget "DLPickerViewTests" */ = { 530 | isa = XCConfigurationList; 531 | buildConfigurations = ( 532 | 0F5DBC441DDE9B4F001CC4B4 /* Debug */, 533 | 0F5DBC451DDE9B4F001CC4B4 /* Release */, 534 | ); 535 | defaultConfigurationIsVisible = 0; 536 | }; 537 | 0F5DBC461DDE9B4F001CC4B4 /* Build configuration list for PBXNativeTarget "DLPickerViewUITests" */ = { 538 | isa = XCConfigurationList; 539 | buildConfigurations = ( 540 | 0F5DBC471DDE9B4F001CC4B4 /* Debug */, 541 | 0F5DBC481DDE9B4F001CC4B4 /* Release */, 542 | ); 543 | defaultConfigurationIsVisible = 0; 544 | }; 545 | /* End XCConfigurationList section */ 546 | }; 547 | rootObject = 0F5DBC0B1DDE9B4F001CC4B4 /* Project object */; 548 | } 549 | -------------------------------------------------------------------------------- /DLPickerView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DLPickerView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // DLPickerView 4 | // 5 | // Created by zuweizhong on 2016/11/18. 6 | // Copyright © 2016年 zuweizhong. 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 | -------------------------------------------------------------------------------- /DLPickerView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // DLPickerView 4 | // 5 | // Created by zuweizhong on 2016/11/18. 6 | // Copyright © 2016年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /DLPickerView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /DLPickerView/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 | -------------------------------------------------------------------------------- /DLPickerView/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 | 34 | 44 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /DLPickerView/DLPickerView/DLPickerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DLPickerView.h 3 | // 4 | // 5 | // Created by zuweizhong on 16/2/1. 6 | // Copyright © 2016年 visoft. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | typedef void(^SelectedBlock) (id item); 14 | 15 | @interface DLPickerView : UIView 16 | 17 | /** 18 | 取消按钮 19 | */ 20 | @property(nonatomic,strong)UIButton * cancelBtn; 21 | /** 22 | 确定按钮 23 | */ 24 | @property(nonatomic,strong)UIButton * confirmBtn; 25 | /** 26 | 点击阴影是否移除PickerView。默认NO 27 | */ 28 | @property(nonatomic,assign)BOOL shouldDismissWhenClickShadow; 29 | 30 | 31 | /** 32 | 创建plist数据源PickerView 33 | 34 | @param plistName plist文件名 35 | @param selectedData 默认选中的行(可传数组) 36 | @param selectedBlock 选择后的回调 37 | @return 实例 38 | */ 39 | - (instancetype)initWithPlistName:(NSString *)plistName 40 | withSelectedItem:(nullable id)selectedData 41 | withSelectedBlock:(SelectedBlock)selectedBlock; 42 | 43 | /** 44 | 创建数组数据源PickerView 45 | 46 | @param dataSource 数组数据源 47 | @param selectedData 默认选中的行(可传数组) 48 | @param selectedBlock 选择后的回调 49 | @return 实例 50 | */ 51 | - (instancetype)initWithDataSource:(NSArray *)dataSource 52 | withSelectedItem:(nullable id)selectedData 53 | withSelectedBlock:(SelectedBlock)selectedBlock; 54 | 55 | /** 56 | 显示DLPickerView 57 | */ 58 | - (void)show; 59 | 60 | /** 61 | 移除DLPickerView 62 | 63 | @param completion 移除完成的Block 64 | */ 65 | - (void)hide:(void (^)(void))completion; 66 | 67 | @end 68 | 69 | NS_ASSUME_NONNULL_END 70 | -------------------------------------------------------------------------------- /DLPickerView/DLPickerView/DLPickerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DLPickerView.m 3 | // 4 | // 5 | // Created by zuweizhong on 16/2/1. 6 | // Copyright © 2016年 visoft. All rights reserved. 7 | // 8 | 9 | #import "DLPickerView.h" 10 | 11 | #define kScreenFrame ([UIScreen mainScreen].bounds) 12 | 13 | #define ShadeViewAlphaWhenShow 0.4 14 | #define ShadeViewAlphaWhenHide 0 15 | 16 | #define PickerBackViewAnimateDuration 0.3 17 | 18 | #define PickerRowHieght 35 19 | 20 | #define PickerHeaderHieght 50 21 | 22 | #define PickerBackViewPointX 0 23 | #define PickerBackViewPointYWhenHide kScreenFrame.size.height 24 | #define PickerBackViewPointYWhenShow (kScreenFrame.size.height - PickerBackViewHieght) 25 | #define PickerBackViewWeight kScreenFrame.size.width 26 | #define PickerBackViewHieght (PickerHeaderHieght + PickerHieght) 27 | 28 | #define PickerPointX 0 29 | #define PickerPointY PickerHeaderHieght 30 | #define PickerWeight kScreenFrame.size.width 31 | #define PickerHieght PickerViewHeightTypeMiddle 32 | 33 | #define HeaderButtonTitleFontSize 17 34 | #define HeaderButtonMargin 15 35 | 36 | #define CancelButtonPointX HeaderButtonMargin 37 | #define CancelButtonPointY 0 38 | #define CancelButtonWeight 50 39 | #define CancelButtonHieght PickerHeaderHieght 40 | #define CancelButtonTitleColor [UIColor colorWithRed:0.26f green:0.56f blue:1.00f alpha:1.00f] 41 | 42 | #define ConfirmButtonPointX (PickerBackViewWeight - HeaderButtonMargin - ConfirmButtonWeight) 43 | #define ConfirmButtonPointY 0 44 | #define ConfirmButtonWeight 50 45 | #define ConfirmButtonHieght PickerHeaderHieght 46 | #define ConfirmButtonTitleColor [UIColor colorWithRed:0.26f green:0.56f blue:1.00f alpha:1.00f] 47 | 48 | BOOL isString(id obj) { 49 | return [obj isKindOfClass:[NSString class]]; 50 | } 51 | 52 | BOOL isArray(id obj) { 53 | return [obj isKindOfClass:[NSArray class]]; 54 | } 55 | 56 | typedef NS_ENUM(NSInteger, PickerViewHeightType) { 57 | PickerViewHeightTypeHeight = 216, 58 | PickerViewHeightTypeMiddle = 180, 59 | PickerViewHeightTypeLow = 162 60 | }; 61 | 62 | @interface DLPickerView () 63 | @property (nonatomic, copy ) SelectedBlock selectedBlock; 64 | @property (nonatomic, copy ) NSArray *dataSource; 65 | @property (nonatomic, copy ) NSString *selectedItem; //Single Column of the selected item 66 | @property (nonatomic, strong) NSMutableArray *selectedItems; //Multiple Column of the selected item 67 | @property (nonatomic, assign) BOOL isSingleColumn; 68 | @property (nonatomic, assign) BOOL isDataSourceValid; 69 | @property (nonatomic, strong) UIView *pickerBackView; 70 | @property (nonatomic, strong) UIButton *shadeView; 71 | @property (nonatomic, strong) UIPickerView *pickerView; 72 | @end 73 | 74 | @implementation DLPickerView 75 | 76 | 77 | #pragma mark - init 78 | - (instancetype)initWithPlistName:(NSString *)plistName 79 | withSelectedItem:(id)selectedData 80 | withSelectedBlock:(SelectedBlock)selectedBlock { 81 | 82 | NSString *path = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"]; 83 | NSArray *dataSource =[[NSArray alloc] initWithContentsOfFile:path]; 84 | return [self initWithDataSource:dataSource 85 | withSelectedItem:selectedData 86 | withSelectedBlock:selectedBlock]; 87 | } 88 | 89 | - (instancetype)initWithDataSource:(NSArray *)dataSource 90 | withSelectedItem:(id)selectedData 91 | withSelectedBlock:(SelectedBlock)selectedBlock { 92 | 93 | self = [super initWithFrame:kScreenFrame]; 94 | if (self) { 95 | self.dataSource = dataSource; 96 | self.selectedBlock = selectedBlock; 97 | if (isString(selectedData)) { 98 | self.selectedItem = selectedData; 99 | } else if (isArray(selectedData)){ 100 | self.selectedItems = [selectedData mutableCopy]; 101 | } 102 | 103 | 104 | [self initData]; 105 | [self initView]; 106 | } 107 | return self; 108 | } 109 | 110 | 111 | #pragma mark - initData 112 | - (void)initData { 113 | if (self.dataSource == nil || self.dataSource.count == 0) { 114 | self.isDataSourceValid = NO; 115 | return; 116 | } else { 117 | self.isDataSourceValid = YES; 118 | } 119 | 120 | __weak typeof(self) weakSelf = self; 121 | [self.dataSource enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 122 | static Class cls; 123 | if (idx == 0) { 124 | cls = [obj class]; 125 | 126 | if (isArray(obj)) { 127 | weakSelf.isSingleColumn = NO; 128 | } else if (isString(obj)) { 129 | weakSelf.isSingleColumn = YES; 130 | } else { 131 | weakSelf.isDataSourceValid = NO; 132 | return; 133 | } 134 | } else { 135 | if (cls != [obj class]) { 136 | weakSelf.isDataSourceValid = NO; 137 | *stop = YES; 138 | return; 139 | } 140 | 141 | if (isArray(obj)) { 142 | if (((NSArray *)obj).count == 0) { 143 | weakSelf.isDataSourceValid = NO; 144 | *stop = YES; 145 | return; 146 | } else { 147 | for (id subObj in obj) { 148 | if (!isString(subObj)) { 149 | weakSelf.isDataSourceValid = NO; 150 | *stop = YES; 151 | return; 152 | } 153 | } 154 | } 155 | } 156 | } 157 | } 158 | ]; 159 | 160 | if (self.isSingleColumn) { 161 | if (self.selectedItem == nil) { 162 | self.selectedItem = self.dataSource.firstObject; 163 | } 164 | } else { 165 | BOOL isSelectedItemsValid = YES; 166 | for (id obj in self.selectedItems) { 167 | if (!isString(obj)) { 168 | isSelectedItemsValid = NO; 169 | break; 170 | } 171 | } 172 | 173 | if (self.selectedItems == nil || self.selectedItems.count != self.dataSource.count || !isSelectedItemsValid) { 174 | NSMutableArray *mutableArray = [NSMutableArray array]; 175 | for (NSArray* componentItem in self.dataSource) { 176 | [mutableArray addObject:componentItem.firstObject]; 177 | } 178 | self.selectedItems = [NSMutableArray arrayWithArray:mutableArray]; 179 | } 180 | } 181 | 182 | } 183 | 184 | #pragma mark - initView 185 | - (void)initView { 186 | [self initBackView]; 187 | [self initPickerBackView]; 188 | [self initPickerHeaderView]; 189 | [self initPickerView]; 190 | } 191 | 192 | -(void)initBackView { 193 | self.shadeView = [[UIButton alloc] initWithFrame:self.frame]; 194 | self.shadeView.userInteractionEnabled = NO; 195 | [self.shadeView addTarget:self action:@selector(shadowViewClick:) forControlEvents:UIControlEventTouchUpInside]; 196 | self.shadeView.backgroundColor = [UIColor blackColor]; 197 | self.shadeView.alpha = ShadeViewAlphaWhenHide; 198 | [self addSubview:self.shadeView]; 199 | } 200 | -(void)shadowViewClick:(UIButton *)btn 201 | { 202 | [self hide:^{ 203 | 204 | }]; 205 | } 206 | -(void)setShouldDismissWhenClickShadow:(BOOL)shouldDismissWhenClickShadow 207 | { 208 | _shouldDismissWhenClickShadow = shouldDismissWhenClickShadow; 209 | if (shouldDismissWhenClickShadow) { 210 | self.shadeView.userInteractionEnabled = YES; 211 | } 212 | } 213 | - (void)initPickerBackView { 214 | self.pickerBackView = [[UIView alloc] initWithFrame:CGRectMake(PickerBackViewPointX, 215 | PickerBackViewPointYWhenHide, 216 | PickerBackViewWeight, 217 | PickerBackViewHieght) 218 | ]; 219 | self.pickerBackView.backgroundColor = [UIColor whiteColor]; 220 | [self addSubview:self.pickerBackView]; 221 | } 222 | 223 | - (void)initPickerHeaderView { 224 | CGRect cancelButtonFrame = CGRectMake(CancelButtonPointX, 225 | CancelButtonPointY, 226 | CancelButtonWeight, 227 | CancelButtonHieght); 228 | 229 | CGRect confirmButtonFrame = CGRectMake(ConfirmButtonPointX , 230 | ConfirmButtonPointY, 231 | ConfirmButtonWeight, 232 | ConfirmButtonHieght); 233 | 234 | UIButton *cancelButton = [[UIButton alloc] initWithFrame:cancelButtonFrame]; 235 | [cancelButton setTitle:@"取消" forState:UIControlStateNormal]; 236 | self.cancelBtn = cancelButton; 237 | [cancelButton setTitleColor:CancelButtonTitleColor forState:UIControlStateNormal]; 238 | [cancelButton addTarget:self action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside]; 239 | cancelButton.titleLabel.font = [UIFont systemFontOfSize:HeaderButtonTitleFontSize]; 240 | [self.pickerBackView addSubview:cancelButton]; 241 | 242 | UIButton *confirmButton = [[UIButton alloc] initWithFrame:confirmButtonFrame]; 243 | self.confirmBtn = confirmButton; 244 | [confirmButton setTitle:@"确定" forState:UIControlStateNormal]; 245 | [confirmButton setTitleColor:ConfirmButtonTitleColor forState:UIControlStateNormal]; 246 | [confirmButton addTarget:self action:@selector(confirm) forControlEvents:UIControlEventTouchUpInside]; 247 | confirmButton.titleLabel.font = [UIFont systemFontOfSize:HeaderButtonTitleFontSize]; 248 | [self.pickerBackView addSubview:confirmButton]; 249 | } 250 | 251 | - (void)initPickerView { 252 | self.pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(PickerPointX, 253 | PickerPointY, 254 | PickerWeight, 255 | PickerHieght) 256 | ]; 257 | [self.pickerBackView addSubview:self.pickerView]; 258 | 259 | if (!self.isDataSourceValid) return; 260 | 261 | self.pickerView.delegate = self; 262 | self.pickerView.dataSource = self; 263 | 264 | __weak typeof(self) weakSelf = self; 265 | if (self.isSingleColumn) { 266 | [self.dataSource enumerateObjectsUsingBlock:^(NSString *rowItem, NSUInteger rowIdx, BOOL *stop) { 267 | if ([weakSelf.selectedItem isEqualToString:rowItem]) { 268 | [weakSelf.pickerView selectRow:rowIdx inComponent:0 animated:NO]; 269 | *stop = YES; 270 | } 271 | } 272 | ]; 273 | } else { 274 | [self.selectedItems enumerateObjectsUsingBlock:^(NSString *selectedItem, NSUInteger component, BOOL *stop) { 275 | [self.dataSource[component] enumerateObjectsUsingBlock:^(id rowItem, NSUInteger rowIdx, BOOL *stop) { 276 | if ([selectedItem isEqualToString:rowItem]) { 277 | [weakSelf.pickerView selectRow:rowIdx inComponent:component animated:NO]; 278 | *stop = YES; 279 | } 280 | } 281 | ]; 282 | } 283 | ]; 284 | } 285 | } 286 | 287 | #pragma mark - Action 288 | - (void)confirm { 289 | [self hide:^{ 290 | if(self.selectedBlock) { 291 | if (self.isSingleColumn) { 292 | self.selectedBlock([self.selectedItem copy]); 293 | } else { 294 | self.selectedBlock([self.selectedItems copy]); 295 | } 296 | } 297 | }]; 298 | } 299 | 300 | - (void)cancel { 301 | [self hide:^{ 302 | 303 | }]; 304 | } 305 | 306 | - (void)hide:(void (^)(void))completion{ 307 | [UIView animateWithDuration:PickerBackViewAnimateDuration 308 | animations:^{ 309 | self.shadeView.alpha = ShadeViewAlphaWhenHide; 310 | self.pickerBackView.frame = CGRectMake(PickerBackViewPointX, 311 | PickerBackViewPointYWhenHide, 312 | PickerBackViewWeight, 313 | PickerBackViewHieght); 314 | } 315 | completion:^(BOOL finished) { 316 | if (finished) { 317 | if (completion) { 318 | completion(); 319 | } 320 | [self removeFromSuperview]; 321 | } 322 | } 323 | ]; 324 | } 325 | 326 | - (void)show { 327 | [[UIApplication sharedApplication].keyWindow addSubview:self]; 328 | [UIView animateWithDuration:PickerBackViewAnimateDuration 329 | animations:^{ 330 | self.shadeView.alpha = ShadeViewAlphaWhenShow; 331 | self.pickerBackView.frame = CGRectMake(PickerBackViewPointX, 332 | PickerBackViewPointYWhenShow, 333 | PickerBackViewWeight, 334 | PickerBackViewHieght); 335 | } 336 | completion:nil 337 | ]; 338 | } 339 | 340 | #pragma mark - UIPickerViewDataSource 341 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 342 | if (self.isSingleColumn) { 343 | return 1; 344 | } else { 345 | return self.dataSource.count; 346 | } 347 | } 348 | 349 | - (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{ 350 | return PickerRowHieght; 351 | } 352 | 353 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 354 | if (self.isSingleColumn) { 355 | return self.dataSource.count; 356 | } else { 357 | return ((NSArray*)self.dataSource[component]).count; 358 | } 359 | } 360 | 361 | #pragma mark - UIPickerViewDelegate 362 | -(NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 363 | if (self.isSingleColumn) { 364 | return self.dataSource[row]; 365 | } else { 366 | return ((NSArray*)self.dataSource[component])[row]; 367 | } 368 | } 369 | 370 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 371 | if (self.isSingleColumn) { 372 | self.selectedItem = self.dataSource[row]; 373 | } else { 374 | self.selectedItems[component] = ((NSArray*)self.dataSource[component])[row]; 375 | } 376 | } 377 | 378 | @end 379 | -------------------------------------------------------------------------------- /DLPickerView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /DLPickerView/Time.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 00 7 | 01 8 | 02 9 | 03 10 | 04 11 | 05 12 | 06 13 | 07 14 | 08 15 | 09 16 | 10 17 | 11 18 | 12 19 | 13 20 | 14 21 | 15 22 | 16 23 | 17 24 | 18 25 | 19 26 | 20 27 | 21 28 | 22 29 | 23 30 | 31 | 32 | 00 33 | 01 34 | 02 35 | 03 36 | 04 37 | 05 38 | 06 39 | 07 40 | 08 41 | 09 42 | 10 43 | 11 44 | 12 45 | 13 46 | 14 47 | 15 48 | 16 49 | 17 50 | 18 51 | 19 52 | 20 53 | 21 54 | 22 55 | 23 56 | 24 57 | 25 58 | 26 59 | 27 60 | 28 61 | 29 62 | 30 63 | 31 64 | 32 65 | 33 66 | 34 67 | 35 68 | 36 69 | 37 70 | 38 71 | 39 72 | 40 73 | 41 74 | 42 75 | 43 76 | 44 77 | 45 78 | 46 79 | 47 80 | 48 81 | 49 82 | 50 83 | 51 84 | 52 85 | 53 86 | 54 87 | 55 88 | 56 89 | 57 90 | 58 91 | 59 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /DLPickerView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // DLPickerView 4 | // 5 | // Created by zuweizhong on 2016/11/18. 6 | // Copyright © 2016年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /DLPickerView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // DLPickerView 4 | // 5 | // Created by zuweizhong on 2016/11/18. 6 | // Copyright © 2016年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "DLPickerView.h" 11 | 12 | #define OwnerSeparator @" - " 13 | #define TimeSeparator @":" 14 | 15 | @interface ViewController () 16 | 17 | @end 18 | 19 | @implementation ViewController 20 | 21 | - (void)viewDidLoad { 22 | [super viewDidLoad]; 23 | // Do any additional setup after loading the view, typically from a nib. 24 | } 25 | 26 | - (IBAction)selectOwner:(UIButton *)sender { 27 | DLPickerView *pickerView = [[DLPickerView alloc] initWithDataSource:@[@[@"Bei Jing",@"Shang Hai"], @[@"Li Lei",@"Han Meimei"]] 28 | withSelectedItem:[sender.titleLabel.text componentsSeparatedByString:OwnerSeparator] 29 | withSelectedBlock:^(id selectedItem) { 30 | [sender setTitle:[selectedItem componentsJoinedByString:OwnerSeparator] forState:UIControlStateNormal]; 31 | } 32 | ]; 33 | 34 | pickerView.shouldDismissWhenClickShadow = YES; 35 | 36 | [pickerView show]; 37 | } 38 | 39 | - (IBAction)selectOwnerGender:(UIButton *)sender { 40 | DLPickerView *pickerView = [[DLPickerView alloc] initWithDataSource:@[@"Man",@"Woman"] 41 | withSelectedItem:sender.titleLabel.text 42 | withSelectedBlock:^(id selectedItem) { 43 | [sender setTitle:selectedItem forState:UIControlStateNormal]; 44 | } 45 | ]; 46 | 47 | [pickerView show]; 48 | } 49 | 50 | - (IBAction)selectTime:(UIButton *)sender { 51 | DLPickerView *pickerView = [[DLPickerView alloc] initWithPlistName:@"Time" 52 | withSelectedItem:[sender.titleLabel.text componentsSeparatedByString:TimeSeparator] 53 | withSelectedBlock:^(id selectedItem) { 54 | [sender setTitle:[selectedItem componentsJoinedByString:TimeSeparator] forState:UIControlStateNormal]; 55 | } 56 | ]; 57 | 58 | [pickerView show]; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /DLPickerView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // DLPickerView 4 | // 5 | // Created by zuweizhong on 2016/11/18. 6 | // Copyright © 2016年 zuweizhong. 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 | -------------------------------------------------------------------------------- /DLPickerViewTests/DLPickerViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DLPickerViewTests.m 3 | // DLPickerViewTests 4 | // 5 | // Created by zuweizhong on 2016/11/18. 6 | // Copyright © 2016年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DLPickerViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation DLPickerViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /DLPickerViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /DLPickerViewUITests/DLPickerViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // DLPickerViewUITests.m 3 | // DLPickerViewUITests 4 | // 5 | // Created by zuweizhong on 2016/11/18. 6 | // Copyright © 2016年 zuweizhong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DLPickerViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation DLPickerViewUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /DLPickerViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Just-coding 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 | # DLPickerView 2 | ##一种支持单列数据选择,多列数据选择,plist读取数据选择的多功能数据选择器,只需改变选择器NSArray数据源即可! 3 | ## Installation 4 | 5 | ### CocoaPods 6 | 7 | DLPickerView is available on [CocoaPods](https://cocoapods.org/). Just add the following to your project Podfile: 8 | 9 | ```ruby 10 | pod 'DLPickerView' # Podfile 11 | ``` 12 | ### 主要功能: 13 | 14 | ![Image text](https://raw.githubusercontent.com/coder-zwz/DLPickerView/master/screenshots/Simulator1.png) 15 | 16 | ### 多列数组数据源: 17 | 18 | ![Image text](https://raw.githubusercontent.com/coder-zwz/DLPickerView/master/screenshots/Simulator2.png) 19 | 20 | ```Objective-C 21 | //多列数组数据源 22 | DLPickerView *pickerView = [[DLPickerView alloc] initWithDataSource:@[@[@"Bei Jing",@"Shang Hai"], @[@"Li Lei",@"Han Meimei"]] 23 | withSelectedItem:[sender.titleLabel.text componentsSeparatedByString:OwnerSeparator] 24 | withSelectedBlock:^(id selectedItem) { 25 | [sender setTitle:[selectedItem componentsJoinedByString:OwnerSeparator] forState:UIControlStateNormal]; 26 | } 27 | ]; 28 | [pickerView show]; 29 | ``` 30 | ### 单列数组数据源: 31 | 32 | ![Image text](https://raw.githubusercontent.com/coder-zwz/DLPickerView/master/screenshots/Simulator3.png) 33 | 34 | ```Objective-C 35 | //单列数组数据源 36 | DLPickerView *pickerView = [[DLPickerView alloc] initWithDataSource:@[@"Man",@"Woman"] 37 | withSelectedItem:sender.titleLabel.text 38 | withSelectedBlock:^(id selectedItem) { 39 | [sender setTitle:selectedItem forState:UIControlStateNormal]; 40 | } 41 | ]; 42 | [pickerView show]; 43 | ``` 44 | ### Plist读取数据源: 45 | 46 | ![Image text](https://raw.githubusercontent.com/coder-zwz/DLPickerView/master/screenshots/Simulator4.png) 47 | 48 | ```Objective-C 49 | //Plist读取数据源 50 | DLPickerView *pickerView = [[DLPickerView alloc] initWithPlistName:@"Time" 51 | withSelectedItem:[sender.titleLabel.text componentsSeparatedByString:TimeSeparator] 52 | withSelectedBlock:^(id selectedItem) { 53 | [sender setTitle:[selectedItem componentsJoinedByString:TimeSeparator] forState:UIControlStateNormal]; 54 | } 55 | ]; 56 | [pickerView show]; 57 | ``` 58 | 59 | 60 | -------------------------------------------------------------------------------- /screenshots/Simulator1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/DLPickerView/1b20490b8bf7719b70fba848fdced9d68033a1c6/screenshots/Simulator1.png -------------------------------------------------------------------------------- /screenshots/Simulator2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/DLPickerView/1b20490b8bf7719b70fba848fdced9d68033a1c6/screenshots/Simulator2.png -------------------------------------------------------------------------------- /screenshots/Simulator3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/DLPickerView/1b20490b8bf7719b70fba848fdced9d68033a1c6/screenshots/Simulator3.png -------------------------------------------------------------------------------- /screenshots/Simulator4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coder-zwz/DLPickerView/1b20490b8bf7719b70fba848fdced9d68033a1c6/screenshots/Simulator4.png --------------------------------------------------------------------------------