├── README.md ├── SimpleSelectionView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── Will.xcuserdatad │ └── xcschemes │ ├── SimpleSelectionView.xcscheme │ └── xcschememanagement.plist ├── SimpleSelectionView ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── downloaded_icon.imageset │ │ ├── Contents.json │ │ └── downloaded_icon@2x.png │ └── homeAddList.imageset │ │ ├── Contents.json │ │ ├── homeAddList@2x.png │ │ └── homeAddList@3x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── WZSelectionView.h ├── WZSelectionView.m └── main.m ├── SimpleSelectionViewTests ├── Info.plist └── SimpleSelectionViewTests.m ├── SimpleSelectionViewUITests ├── Info.plist └── SimpleSelectionViewUITests.m └── a.txt /README.md: -------------------------------------------------------------------------------- 1 | # SimpleSelectionView 2 | 3 | Demo介绍看这个链接:[链接](http://www.reviewcode.cn/article.html?reviewId=5) -------------------------------------------------------------------------------- /SimpleSelectionView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BEB49E891C73477B001EDD39 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BEB49E881C73477B001EDD39 /* main.m */; }; 11 | BEB49E8C1C73477B001EDD39 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BEB49E8B1C73477B001EDD39 /* AppDelegate.m */; }; 12 | BEB49E8F1C73477B001EDD39 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BEB49E8E1C73477B001EDD39 /* ViewController.m */; }; 13 | BEB49E921C73477B001EDD39 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BEB49E901C73477B001EDD39 /* Main.storyboard */; }; 14 | BEB49E941C73477B001EDD39 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BEB49E931C73477B001EDD39 /* Assets.xcassets */; }; 15 | BEB49E971C73477B001EDD39 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BEB49E951C73477B001EDD39 /* LaunchScreen.storyboard */; }; 16 | BEB49EA21C73477B001EDD39 /* SimpleSelectionViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BEB49EA11C73477B001EDD39 /* SimpleSelectionViewTests.m */; }; 17 | BEB49EAD1C73477B001EDD39 /* SimpleSelectionViewUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = BEB49EAC1C73477B001EDD39 /* SimpleSelectionViewUITests.m */; }; 18 | BEB49EBC1C734788001EDD39 /* WZSelectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = BEB49EBB1C734788001EDD39 /* WZSelectionView.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | BEB49E9E1C73477B001EDD39 /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = BEB49E7C1C73477B001EDD39 /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = BEB49E831C73477B001EDD39; 27 | remoteInfo = SimpleSelectionView; 28 | }; 29 | BEB49EA91C73477B001EDD39 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = BEB49E7C1C73477B001EDD39 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = BEB49E831C73477B001EDD39; 34 | remoteInfo = SimpleSelectionView; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | BEB49E841C73477B001EDD39 /* SimpleSelectionView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SimpleSelectionView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | BEB49E881C73477B001EDD39 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | BEB49E8A1C73477B001EDD39 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | BEB49E8B1C73477B001EDD39 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | BEB49E8D1C73477B001EDD39 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | BEB49E8E1C73477B001EDD39 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | BEB49E911C73477B001EDD39 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | BEB49E931C73477B001EDD39 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | BEB49E961C73477B001EDD39 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | BEB49E981C73477B001EDD39 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | BEB49E9D1C73477B001EDD39 /* SimpleSelectionViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SimpleSelectionViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | BEB49EA11C73477B001EDD39 /* SimpleSelectionViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleSelectionViewTests.m; sourceTree = ""; }; 51 | BEB49EA31C73477B001EDD39 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | BEB49EA81C73477B001EDD39 /* SimpleSelectionViewUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SimpleSelectionViewUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | BEB49EAC1C73477B001EDD39 /* SimpleSelectionViewUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SimpleSelectionViewUITests.m; sourceTree = ""; }; 54 | BEB49EAE1C73477B001EDD39 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | BEB49EBA1C734788001EDD39 /* WZSelectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WZSelectionView.h; sourceTree = ""; }; 56 | BEB49EBB1C734788001EDD39 /* WZSelectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WZSelectionView.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | BEB49E811C73477B001EDD39 /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | BEB49E9A1C73477B001EDD39 /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | BEB49EA51C73477B001EDD39 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | BEB49E7B1C73477B001EDD39 = { 85 | isa = PBXGroup; 86 | children = ( 87 | BEB49E861C73477B001EDD39 /* SimpleSelectionView */, 88 | BEB49EA01C73477B001EDD39 /* SimpleSelectionViewTests */, 89 | BEB49EAB1C73477B001EDD39 /* SimpleSelectionViewUITests */, 90 | BEB49E851C73477B001EDD39 /* Products */, 91 | ); 92 | sourceTree = ""; 93 | }; 94 | BEB49E851C73477B001EDD39 /* Products */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | BEB49E841C73477B001EDD39 /* SimpleSelectionView.app */, 98 | BEB49E9D1C73477B001EDD39 /* SimpleSelectionViewTests.xctest */, 99 | BEB49EA81C73477B001EDD39 /* SimpleSelectionViewUITests.xctest */, 100 | ); 101 | name = Products; 102 | sourceTree = ""; 103 | }; 104 | BEB49E861C73477B001EDD39 /* SimpleSelectionView */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | BEB49E8A1C73477B001EDD39 /* AppDelegate.h */, 108 | BEB49E8B1C73477B001EDD39 /* AppDelegate.m */, 109 | BEB49EBA1C734788001EDD39 /* WZSelectionView.h */, 110 | BEB49EBB1C734788001EDD39 /* WZSelectionView.m */, 111 | BEB49E8D1C73477B001EDD39 /* ViewController.h */, 112 | BEB49E8E1C73477B001EDD39 /* ViewController.m */, 113 | BEB49E901C73477B001EDD39 /* Main.storyboard */, 114 | BEB49E931C73477B001EDD39 /* Assets.xcassets */, 115 | BEB49E951C73477B001EDD39 /* LaunchScreen.storyboard */, 116 | BEB49E981C73477B001EDD39 /* Info.plist */, 117 | BEB49E871C73477B001EDD39 /* Supporting Files */, 118 | ); 119 | path = SimpleSelectionView; 120 | sourceTree = ""; 121 | }; 122 | BEB49E871C73477B001EDD39 /* Supporting Files */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | BEB49E881C73477B001EDD39 /* main.m */, 126 | ); 127 | name = "Supporting Files"; 128 | sourceTree = ""; 129 | }; 130 | BEB49EA01C73477B001EDD39 /* SimpleSelectionViewTests */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | BEB49EA11C73477B001EDD39 /* SimpleSelectionViewTests.m */, 134 | BEB49EA31C73477B001EDD39 /* Info.plist */, 135 | ); 136 | path = SimpleSelectionViewTests; 137 | sourceTree = ""; 138 | }; 139 | BEB49EAB1C73477B001EDD39 /* SimpleSelectionViewUITests */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | BEB49EAC1C73477B001EDD39 /* SimpleSelectionViewUITests.m */, 143 | BEB49EAE1C73477B001EDD39 /* Info.plist */, 144 | ); 145 | path = SimpleSelectionViewUITests; 146 | sourceTree = ""; 147 | }; 148 | /* End PBXGroup section */ 149 | 150 | /* Begin PBXNativeTarget section */ 151 | BEB49E831C73477B001EDD39 /* SimpleSelectionView */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = BEB49EB11C73477B001EDD39 /* Build configuration list for PBXNativeTarget "SimpleSelectionView" */; 154 | buildPhases = ( 155 | BEB49E801C73477B001EDD39 /* Sources */, 156 | BEB49E811C73477B001EDD39 /* Frameworks */, 157 | BEB49E821C73477B001EDD39 /* Resources */, 158 | ); 159 | buildRules = ( 160 | ); 161 | dependencies = ( 162 | ); 163 | name = SimpleSelectionView; 164 | productName = SimpleSelectionView; 165 | productReference = BEB49E841C73477B001EDD39 /* SimpleSelectionView.app */; 166 | productType = "com.apple.product-type.application"; 167 | }; 168 | BEB49E9C1C73477B001EDD39 /* SimpleSelectionViewTests */ = { 169 | isa = PBXNativeTarget; 170 | buildConfigurationList = BEB49EB41C73477B001EDD39 /* Build configuration list for PBXNativeTarget "SimpleSelectionViewTests" */; 171 | buildPhases = ( 172 | BEB49E991C73477B001EDD39 /* Sources */, 173 | BEB49E9A1C73477B001EDD39 /* Frameworks */, 174 | BEB49E9B1C73477B001EDD39 /* Resources */, 175 | ); 176 | buildRules = ( 177 | ); 178 | dependencies = ( 179 | BEB49E9F1C73477B001EDD39 /* PBXTargetDependency */, 180 | ); 181 | name = SimpleSelectionViewTests; 182 | productName = SimpleSelectionViewTests; 183 | productReference = BEB49E9D1C73477B001EDD39 /* SimpleSelectionViewTests.xctest */; 184 | productType = "com.apple.product-type.bundle.unit-test"; 185 | }; 186 | BEB49EA71C73477B001EDD39 /* SimpleSelectionViewUITests */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = BEB49EB71C73477B001EDD39 /* Build configuration list for PBXNativeTarget "SimpleSelectionViewUITests" */; 189 | buildPhases = ( 190 | BEB49EA41C73477B001EDD39 /* Sources */, 191 | BEB49EA51C73477B001EDD39 /* Frameworks */, 192 | BEB49EA61C73477B001EDD39 /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | BEB49EAA1C73477B001EDD39 /* PBXTargetDependency */, 198 | ); 199 | name = SimpleSelectionViewUITests; 200 | productName = SimpleSelectionViewUITests; 201 | productReference = BEB49EA81C73477B001EDD39 /* SimpleSelectionViewUITests.xctest */; 202 | productType = "com.apple.product-type.bundle.ui-testing"; 203 | }; 204 | /* End PBXNativeTarget section */ 205 | 206 | /* Begin PBXProject section */ 207 | BEB49E7C1C73477B001EDD39 /* Project object */ = { 208 | isa = PBXProject; 209 | attributes = { 210 | LastUpgradeCheck = 0720; 211 | ORGANIZATIONNAME = " Will"; 212 | TargetAttributes = { 213 | BEB49E831C73477B001EDD39 = { 214 | CreatedOnToolsVersion = 7.2.1; 215 | }; 216 | BEB49E9C1C73477B001EDD39 = { 217 | CreatedOnToolsVersion = 7.2.1; 218 | TestTargetID = BEB49E831C73477B001EDD39; 219 | }; 220 | BEB49EA71C73477B001EDD39 = { 221 | CreatedOnToolsVersion = 7.2.1; 222 | TestTargetID = BEB49E831C73477B001EDD39; 223 | }; 224 | }; 225 | }; 226 | buildConfigurationList = BEB49E7F1C73477B001EDD39 /* Build configuration list for PBXProject "SimpleSelectionView" */; 227 | compatibilityVersion = "Xcode 3.2"; 228 | developmentRegion = English; 229 | hasScannedForEncodings = 0; 230 | knownRegions = ( 231 | en, 232 | Base, 233 | ); 234 | mainGroup = BEB49E7B1C73477B001EDD39; 235 | productRefGroup = BEB49E851C73477B001EDD39 /* Products */; 236 | projectDirPath = ""; 237 | projectRoot = ""; 238 | targets = ( 239 | BEB49E831C73477B001EDD39 /* SimpleSelectionView */, 240 | BEB49E9C1C73477B001EDD39 /* SimpleSelectionViewTests */, 241 | BEB49EA71C73477B001EDD39 /* SimpleSelectionViewUITests */, 242 | ); 243 | }; 244 | /* End PBXProject section */ 245 | 246 | /* Begin PBXResourcesBuildPhase section */ 247 | BEB49E821C73477B001EDD39 /* Resources */ = { 248 | isa = PBXResourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | BEB49E971C73477B001EDD39 /* LaunchScreen.storyboard in Resources */, 252 | BEB49E941C73477B001EDD39 /* Assets.xcassets in Resources */, 253 | BEB49E921C73477B001EDD39 /* Main.storyboard in Resources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | BEB49E9B1C73477B001EDD39 /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | runOnlyForDeploymentPostprocessing = 0; 263 | }; 264 | BEB49EA61C73477B001EDD39 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | /* End PBXResourcesBuildPhase section */ 272 | 273 | /* Begin PBXSourcesBuildPhase section */ 274 | BEB49E801C73477B001EDD39 /* Sources */ = { 275 | isa = PBXSourcesBuildPhase; 276 | buildActionMask = 2147483647; 277 | files = ( 278 | BEB49E8F1C73477B001EDD39 /* ViewController.m in Sources */, 279 | BEB49EBC1C734788001EDD39 /* WZSelectionView.m in Sources */, 280 | BEB49E8C1C73477B001EDD39 /* AppDelegate.m in Sources */, 281 | BEB49E891C73477B001EDD39 /* main.m in Sources */, 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | }; 285 | BEB49E991C73477B001EDD39 /* Sources */ = { 286 | isa = PBXSourcesBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | BEB49EA21C73477B001EDD39 /* SimpleSelectionViewTests.m in Sources */, 290 | ); 291 | runOnlyForDeploymentPostprocessing = 0; 292 | }; 293 | BEB49EA41C73477B001EDD39 /* Sources */ = { 294 | isa = PBXSourcesBuildPhase; 295 | buildActionMask = 2147483647; 296 | files = ( 297 | BEB49EAD1C73477B001EDD39 /* SimpleSelectionViewUITests.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXTargetDependency section */ 304 | BEB49E9F1C73477B001EDD39 /* PBXTargetDependency */ = { 305 | isa = PBXTargetDependency; 306 | target = BEB49E831C73477B001EDD39 /* SimpleSelectionView */; 307 | targetProxy = BEB49E9E1C73477B001EDD39 /* PBXContainerItemProxy */; 308 | }; 309 | BEB49EAA1C73477B001EDD39 /* PBXTargetDependency */ = { 310 | isa = PBXTargetDependency; 311 | target = BEB49E831C73477B001EDD39 /* SimpleSelectionView */; 312 | targetProxy = BEB49EA91C73477B001EDD39 /* PBXContainerItemProxy */; 313 | }; 314 | /* End PBXTargetDependency section */ 315 | 316 | /* Begin PBXVariantGroup section */ 317 | BEB49E901C73477B001EDD39 /* Main.storyboard */ = { 318 | isa = PBXVariantGroup; 319 | children = ( 320 | BEB49E911C73477B001EDD39 /* Base */, 321 | ); 322 | name = Main.storyboard; 323 | sourceTree = ""; 324 | }; 325 | BEB49E951C73477B001EDD39 /* LaunchScreen.storyboard */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | BEB49E961C73477B001EDD39 /* Base */, 329 | ); 330 | name = LaunchScreen.storyboard; 331 | sourceTree = ""; 332 | }; 333 | /* End PBXVariantGroup section */ 334 | 335 | /* Begin XCBuildConfiguration section */ 336 | BEB49EAF1C73477B001EDD39 /* Debug */ = { 337 | isa = XCBuildConfiguration; 338 | buildSettings = { 339 | ALWAYS_SEARCH_USER_PATHS = NO; 340 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 341 | CLANG_CXX_LIBRARY = "libc++"; 342 | CLANG_ENABLE_MODULES = YES; 343 | CLANG_ENABLE_OBJC_ARC = YES; 344 | CLANG_WARN_BOOL_CONVERSION = YES; 345 | CLANG_WARN_CONSTANT_CONVERSION = YES; 346 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 347 | CLANG_WARN_EMPTY_BODY = YES; 348 | CLANG_WARN_ENUM_CONVERSION = YES; 349 | CLANG_WARN_INT_CONVERSION = YES; 350 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 354 | COPY_PHASE_STRIP = NO; 355 | DEBUG_INFORMATION_FORMAT = dwarf; 356 | ENABLE_STRICT_OBJC_MSGSEND = YES; 357 | ENABLE_TESTABILITY = YES; 358 | GCC_C_LANGUAGE_STANDARD = gnu99; 359 | GCC_DYNAMIC_NO_PIC = NO; 360 | GCC_NO_COMMON_BLOCKS = YES; 361 | GCC_OPTIMIZATION_LEVEL = 0; 362 | GCC_PREPROCESSOR_DEFINITIONS = ( 363 | "DEBUG=1", 364 | "$(inherited)", 365 | ); 366 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 367 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 368 | GCC_WARN_UNDECLARED_SELECTOR = YES; 369 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 370 | GCC_WARN_UNUSED_FUNCTION = YES; 371 | GCC_WARN_UNUSED_VARIABLE = YES; 372 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 373 | MTL_ENABLE_DEBUG_INFO = YES; 374 | ONLY_ACTIVE_ARCH = YES; 375 | SDKROOT = iphoneos; 376 | }; 377 | name = Debug; 378 | }; 379 | BEB49EB01C73477B001EDD39 /* Release */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | ALWAYS_SEARCH_USER_PATHS = NO; 383 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 384 | CLANG_CXX_LIBRARY = "libc++"; 385 | CLANG_ENABLE_MODULES = YES; 386 | CLANG_ENABLE_OBJC_ARC = YES; 387 | CLANG_WARN_BOOL_CONVERSION = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 390 | CLANG_WARN_EMPTY_BODY = YES; 391 | CLANG_WARN_ENUM_CONVERSION = YES; 392 | CLANG_WARN_INT_CONVERSION = YES; 393 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 394 | CLANG_WARN_UNREACHABLE_CODE = YES; 395 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 396 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 397 | COPY_PHASE_STRIP = NO; 398 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 399 | ENABLE_NS_ASSERTIONS = NO; 400 | ENABLE_STRICT_OBJC_MSGSEND = YES; 401 | GCC_C_LANGUAGE_STANDARD = gnu99; 402 | GCC_NO_COMMON_BLOCKS = YES; 403 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 404 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 405 | GCC_WARN_UNDECLARED_SELECTOR = YES; 406 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 407 | GCC_WARN_UNUSED_FUNCTION = YES; 408 | GCC_WARN_UNUSED_VARIABLE = YES; 409 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 410 | MTL_ENABLE_DEBUG_INFO = NO; 411 | SDKROOT = iphoneos; 412 | VALIDATE_PRODUCT = YES; 413 | }; 414 | name = Release; 415 | }; 416 | BEB49EB21C73477B001EDD39 /* Debug */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 420 | INFOPLIST_FILE = SimpleSelectionView/Info.plist; 421 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 422 | PRODUCT_BUNDLE_IDENTIFIER = Will.SimpleSelectionView; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | }; 425 | name = Debug; 426 | }; 427 | BEB49EB31C73477B001EDD39 /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 431 | INFOPLIST_FILE = SimpleSelectionView/Info.plist; 432 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 433 | PRODUCT_BUNDLE_IDENTIFIER = Will.SimpleSelectionView; 434 | PRODUCT_NAME = "$(TARGET_NAME)"; 435 | }; 436 | name = Release; 437 | }; 438 | BEB49EB51C73477B001EDD39 /* Debug */ = { 439 | isa = XCBuildConfiguration; 440 | buildSettings = { 441 | BUNDLE_LOADER = "$(TEST_HOST)"; 442 | INFOPLIST_FILE = SimpleSelectionViewTests/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 444 | PRODUCT_BUNDLE_IDENTIFIER = Will.SimpleSelectionViewTests; 445 | PRODUCT_NAME = "$(TARGET_NAME)"; 446 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleSelectionView.app/SimpleSelectionView"; 447 | }; 448 | name = Debug; 449 | }; 450 | BEB49EB61C73477B001EDD39 /* Release */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | BUNDLE_LOADER = "$(TEST_HOST)"; 454 | INFOPLIST_FILE = SimpleSelectionViewTests/Info.plist; 455 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 456 | PRODUCT_BUNDLE_IDENTIFIER = Will.SimpleSelectionViewTests; 457 | PRODUCT_NAME = "$(TARGET_NAME)"; 458 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SimpleSelectionView.app/SimpleSelectionView"; 459 | }; 460 | name = Release; 461 | }; 462 | BEB49EB81C73477B001EDD39 /* Debug */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | INFOPLIST_FILE = SimpleSelectionViewUITests/Info.plist; 466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 467 | PRODUCT_BUNDLE_IDENTIFIER = Will.SimpleSelectionViewUITests; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | TEST_TARGET_NAME = SimpleSelectionView; 470 | USES_XCTRUNNER = YES; 471 | }; 472 | name = Debug; 473 | }; 474 | BEB49EB91C73477B001EDD39 /* Release */ = { 475 | isa = XCBuildConfiguration; 476 | buildSettings = { 477 | INFOPLIST_FILE = SimpleSelectionViewUITests/Info.plist; 478 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 479 | PRODUCT_BUNDLE_IDENTIFIER = Will.SimpleSelectionViewUITests; 480 | PRODUCT_NAME = "$(TARGET_NAME)"; 481 | TEST_TARGET_NAME = SimpleSelectionView; 482 | USES_XCTRUNNER = YES; 483 | }; 484 | name = Release; 485 | }; 486 | /* End XCBuildConfiguration section */ 487 | 488 | /* Begin XCConfigurationList section */ 489 | BEB49E7F1C73477B001EDD39 /* Build configuration list for PBXProject "SimpleSelectionView" */ = { 490 | isa = XCConfigurationList; 491 | buildConfigurations = ( 492 | BEB49EAF1C73477B001EDD39 /* Debug */, 493 | BEB49EB01C73477B001EDD39 /* Release */, 494 | ); 495 | defaultConfigurationIsVisible = 0; 496 | defaultConfigurationName = Release; 497 | }; 498 | BEB49EB11C73477B001EDD39 /* Build configuration list for PBXNativeTarget "SimpleSelectionView" */ = { 499 | isa = XCConfigurationList; 500 | buildConfigurations = ( 501 | BEB49EB21C73477B001EDD39 /* Debug */, 502 | BEB49EB31C73477B001EDD39 /* Release */, 503 | ); 504 | defaultConfigurationIsVisible = 0; 505 | }; 506 | BEB49EB41C73477B001EDD39 /* Build configuration list for PBXNativeTarget "SimpleSelectionViewTests" */ = { 507 | isa = XCConfigurationList; 508 | buildConfigurations = ( 509 | BEB49EB51C73477B001EDD39 /* Debug */, 510 | BEB49EB61C73477B001EDD39 /* Release */, 511 | ); 512 | defaultConfigurationIsVisible = 0; 513 | }; 514 | BEB49EB71C73477B001EDD39 /* Build configuration list for PBXNativeTarget "SimpleSelectionViewUITests" */ = { 515 | isa = XCConfigurationList; 516 | buildConfigurations = ( 517 | BEB49EB81C73477B001EDD39 /* Debug */, 518 | BEB49EB91C73477B001EDD39 /* Release */, 519 | ); 520 | defaultConfigurationIsVisible = 0; 521 | }; 522 | /* End XCConfigurationList section */ 523 | }; 524 | rootObject = BEB49E7C1C73477B001EDD39 /* Project object */; 525 | } 526 | -------------------------------------------------------------------------------- /SimpleSelectionView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SimpleSelectionView.xcodeproj/xcuserdata/Will.xcuserdatad/xcschemes/SimpleSelectionView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 43 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 74 | 76 | 82 | 83 | 84 | 85 | 86 | 87 | 93 | 95 | 101 | 102 | 103 | 104 | 106 | 107 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /SimpleSelectionView.xcodeproj/xcuserdata/Will.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SimpleSelectionView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | BEB49E831C73477B001EDD39 16 | 17 | primary 18 | 19 | 20 | BEB49E9C1C73477B001EDD39 21 | 22 | primary 23 | 24 | 25 | BEB49EA71C73477B001EDD39 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /SimpleSelectionView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SimpleSelectionView 4 | // 5 | // Created by  Will on 16/2/16. 6 | // Copyright © 2016年  Will. 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 | -------------------------------------------------------------------------------- /SimpleSelectionView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SimpleSelectionView 4 | // 5 | // Created by  Will on 16/2/16. 6 | // Copyright © 2016年  Will. 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 | -------------------------------------------------------------------------------- /SimpleSelectionView/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 | } -------------------------------------------------------------------------------- /SimpleSelectionView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SimpleSelectionView/Assets.xcassets/downloaded_icon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "downloaded_icon@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SimpleSelectionView/Assets.xcassets/downloaded_icon.imageset/downloaded_icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyanrui/SimpleSelectionView/582681b216b4bc831aaab94a91cce9cdc39b0aa6/SimpleSelectionView/Assets.xcassets/downloaded_icon.imageset/downloaded_icon@2x.png -------------------------------------------------------------------------------- /SimpleSelectionView/Assets.xcassets/homeAddList.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "homeAddList@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "homeAddList@3x.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /SimpleSelectionView/Assets.xcassets/homeAddList.imageset/homeAddList@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyanrui/SimpleSelectionView/582681b216b4bc831aaab94a91cce9cdc39b0aa6/SimpleSelectionView/Assets.xcassets/homeAddList.imageset/homeAddList@2x.png -------------------------------------------------------------------------------- /SimpleSelectionView/Assets.xcassets/homeAddList.imageset/homeAddList@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyanrui/SimpleSelectionView/582681b216b4bc831aaab94a91cce9cdc39b0aa6/SimpleSelectionView/Assets.xcassets/homeAddList.imageset/homeAddList@3x.png -------------------------------------------------------------------------------- /SimpleSelectionView/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 | -------------------------------------------------------------------------------- /SimpleSelectionView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /SimpleSelectionView/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 | -------------------------------------------------------------------------------- /SimpleSelectionView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SimpleSelectionView 4 | // 5 | // Created by  Will on 16/2/16. 6 | // Copyright © 2016年  Will. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SimpleSelectionView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SimpleSelectionView 4 | // 5 | // Created by  Will on 16/2/16. 6 | // Copyright © 2016年  Will. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "WZSelectionView.h" 11 | 12 | @interface ViewController () 13 | 14 | @end 15 | 16 | @implementation ViewController 17 | 18 | - (void)viewDidLoad { 19 | [super viewDidLoad]; 20 | 21 | } 22 | - (IBAction)showSelectionView:(id)sender { 23 | 24 | [WZSelectionView showWithItemsBlock:^(id items) { 25 | [items addItemWithLabelText:@"加入乐影单" imageName:@"homeAddList" shouldDismiss:YES]; 26 | [items addItemWithLabelText:@"下载" imageName:@"downloaded_icon" shouldDismiss:YES]; 27 | } selectedBlock:^(NSInteger selectedTag) { 28 | 29 | [self showTipsWithSelectedIndex:selectedTag]; 30 | 31 | }]; 32 | } 33 | 34 | 35 | - (void)showTipsWithSelectedIndex:(NSInteger)selectedIndex { 36 | 37 | NSDictionary *tipsInfoDic = @{@0 : @"已加入乐影单", @1 : @"下载中..."}; 38 | 39 | NSNumber *selectedNumber = [NSNumber numberWithInteger:selectedIndex]; 40 | NSString *tipsString = tipsInfoDic[selectedNumber]; 41 | 42 | UIAlertController *alert = [UIAlertController alertControllerWithTitle:tipsString message:nil preferredStyle:UIAlertControllerStyleAlert]; 43 | 44 | [self presentViewController:alert animated:YES completion:^{ 45 | 46 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 47 | [alert dismissViewControllerAnimated:YES completion:nil]; 48 | }); 49 | 50 | }]; 51 | 52 | } 53 | 54 | - (void)didReceiveMemoryWarning { 55 | [super didReceiveMemoryWarning]; 56 | // Dispose of any resources that can be recreated. 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /SimpleSelectionView/WZSelectionView.h: -------------------------------------------------------------------------------- 1 | // 2 | // WZSelectionView.h 3 | // LeFilm 4 | // 5 | // Created by  Will on 15/11/12. 6 | // Copyright © 2015年 LEVP. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #define kSelectionCellHeight 58 12 | #define KSelectionViewMaxHeight 320 13 | 14 | @protocol WZSelectionItemsProtocol 15 | 16 | @required 17 | - (void)addItemWithLabelText:(NSString *)labelText imageName:(NSString *)imageName shouldDismiss:(BOOL)shouldDismiss; 18 | 19 | @end 20 | 21 | typedef void(^ITtemsBlock)(id items); 22 | typedef void(^SelectedTodoBlock)(NSInteger selectedTag); 23 | 24 | @interface WZSelectionView : UIView 25 | 26 | + (void)showWithItemsBlock:(ITtemsBlock)itemsBlock selectedBlock:(SelectedTodoBlock)selectedBlock; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /SimpleSelectionView/WZSelectionView.m: -------------------------------------------------------------------------------- 1 | // 2 | // WZSelectionView.m 3 | // LeFilm 4 | // 5 | // Created by  Will on 15/11/12. 6 | // Copyright © 2015年 LEVP. All rights reserved. 7 | // 8 | 9 | #import "WZSelectionView.h" 10 | 11 | static NSString *const kSelectionCellNameKey = @"SelectionCellNameKey"; 12 | static NSString *const kSelectionCellImageNameKey = @"SelectionCellImageNameKey"; 13 | static NSString *const kSelectionCellTagKey = @"SelectionCellTagKey"; 14 | static NSString *const kSelectionViewShouldDismissKey = @"SelectionViewShouldDismissKey"; 15 | 16 | #define kColorWithHex(c) [UIColor colorWithRed:((c>>16)&0xFF)/255.0f green:((c>>8)&0xFF)/255.0f blue:(c&0xFF)/255.0f alpha:1.0f] 17 | 18 | 19 | 20 | #pragma mark - WZSelectionItems 21 | 22 | @interface WZSelectionItems : NSObject 23 | 24 | @property (nonatomic, strong) NSMutableArray *itemsArray; 25 | - (NSInteger) count; 26 | 27 | @end 28 | 29 | 30 | @implementation WZSelectionItems 31 | 32 | - (instancetype)init{ 33 | self = [super init]; 34 | if (self) { 35 | self.itemsArray = [NSMutableArray array]; 36 | } 37 | return self; 38 | } 39 | 40 | 41 | - (void)addItemWithLabelText:(NSString *)labelText imageName:(NSString *)imageName shouldDismiss:(BOOL)shouldDismiss{ 42 | if (labelText && [labelText isKindOfClass:[NSString class]] && imageName && [imageName isKindOfClass:[NSString class]]) { 43 | NSDictionary *itemDic = [NSDictionary dictionaryWithObjectsAndKeys: labelText, kSelectionCellNameKey, imageName, kSelectionCellImageNameKey, [NSNumber numberWithBool:shouldDismiss], kSelectionViewShouldDismissKey, nil]; 44 | [self.itemsArray addObject:itemDic]; 45 | } 46 | } 47 | 48 | - (NSInteger)count{ 49 | return self.itemsArray.count; 50 | } 51 | 52 | @end 53 | 54 | 55 | 56 | #pragma mark - WZSelectionCell 57 | 58 | @interface WZSelectionCell : UITableViewCell 59 | 60 | @property (nonatomic, strong)UIImageView *pictureView; 61 | @property (nonatomic, strong)UILabel *labelView; 62 | @property (nonatomic, strong)UIView *lineView; 63 | @property (nonatomic, strong)NSDictionary *infoDictionary; 64 | 65 | @end 66 | 67 | @implementation WZSelectionCell 68 | 69 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 70 | { 71 | if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 72 | 73 | //图片 74 | UIImageView *pictureView=[[UIImageView alloc]init]; 75 | self.pictureView=pictureView; 76 | pictureView.backgroundColor = [UIColor clearColor]; 77 | [self.contentView addSubview:pictureView]; 78 | 79 | //文字 80 | UILabel *labelView=[[UILabel alloc]init]; 81 | labelView.backgroundColor = [UIColor clearColor]; 82 | labelView.font=[UIFont systemFontOfSize:16]; 83 | [labelView setTextColor:[UIColor colorWithRed:39/255.0 green:44/255.0 blue:47/255.0 alpha:1.0]]; 84 | self.labelView=labelView; 85 | [self.contentView addSubview:labelView]; 86 | 87 | //下划线 88 | UIView *lineView=[[UIView alloc]init]; 89 | self.lineView=lineView; 90 | lineView.backgroundColor = kColorWithHex(0xd2d5d9); 91 | [self.contentView addSubview:lineView]; 92 | 93 | UIView *selectedBackgroundView = [[UIView alloc] init]; 94 | selectedBackgroundView.backgroundColor = kColorWithHex(0xf5f6f7); 95 | self.selectedBackgroundView = selectedBackgroundView; 96 | 97 | self.contentView.backgroundColor = kColorWithHex(0xffffff); 98 | 99 | } 100 | return self; 101 | } 102 | 103 | 104 | -(void)layoutSubviews 105 | { 106 | 107 | [super layoutSubviews]; 108 | 109 | CGFloat picW=24; 110 | CGFloat picH=24; 111 | CGFloat picX=8; 112 | CGFloat picY=self.bounds.size.height*0.5-picH*0.5; 113 | self.pictureView.frame=CGRectMake(picX, picY, picW, picH); 114 | 115 | CGFloat labelX=CGRectGetMaxX(self.pictureView.frame)+8; 116 | CGFloat labelY=0; 117 | CGFloat labelW=self.bounds.size.width-labelX; 118 | CGFloat labelH=self.bounds.size.height; 119 | self.labelView.frame=CGRectMake(labelX, labelY, labelW, labelH); 120 | 121 | 122 | CGFloat lineX=0; 123 | CGFloat lineW=self.bounds.size.width-lineX; 124 | CGFloat lineH=0.5; 125 | CGFloat lineY=self.bounds.size.height-lineH; 126 | self.lineView.frame=CGRectMake(lineX, lineY, lineW, lineH); 127 | 128 | } 129 | 130 | -(void)setInfoDictionary:(NSDictionary *)infoDictionary{ 131 | _infoDictionary = infoDictionary; 132 | NSString *imageName = infoDictionary[kSelectionCellImageNameKey]; 133 | if (imageName && [imageName isKindOfClass:[NSString class]] && imageName.length) { 134 | self.pictureView.image=[UIImage imageNamed:imageName]; 135 | } 136 | 137 | NSString *nameStr = infoDictionary[kSelectionCellNameKey]; 138 | self.labelView.text = [nameStr description]; 139 | 140 | } 141 | @end 142 | 143 | 144 | 145 | #pragma mark - WZSelectionCancelCell 146 | 147 | @interface WZSelectionCancelCell : UITableViewCell 148 | 149 | @property (nonatomic, strong)UILabel *labelView; 150 | 151 | @end 152 | 153 | @implementation WZSelectionCancelCell 154 | 155 | -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ 156 | if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) { 157 | 158 | UILabel *labelView=[[UILabel alloc]init]; 159 | labelView.text=@"取消"; 160 | [self.contentView addSubview:labelView]; 161 | self.labelView=labelView; 162 | labelView.textAlignment=NSTextAlignmentCenter; 163 | labelView.font=[UIFont systemFontOfSize:16]; 164 | [labelView setTextColor:[UIColor colorWithRed:104/255.0 green:165/255.0 blue:225/255.0 alpha:1.0]]; 165 | } 166 | return self; 167 | } 168 | 169 | -(void)layoutSubviews{ 170 | [super layoutSubviews]; 171 | CGFloat labelX=0; 172 | CGFloat labelY=0; 173 | CGFloat labelW=self.bounds.size.width; 174 | CGFloat labelH=self.bounds.size.height; 175 | self.labelView.frame=CGRectMake(labelX, labelY, labelW, labelH); 176 | } 177 | 178 | @end 179 | 180 | 181 | 182 | 183 | 184 | 185 | #pragma mark - WZSelectionView 186 | 187 | 188 | @interface WZSelectionView () 189 | 190 | @property (nonatomic, strong)UITableView *selectionTableView; 191 | @property (nonatomic, strong)WZSelectionItems *items; 192 | @property (nonatomic, copy) void (^seletedBlock)(NSInteger selectedIndex); 193 | 194 | @end 195 | 196 | 197 | @implementation WZSelectionView 198 | 199 | - (instancetype)initWithFrame:(CGRect)frame{ 200 | self = [super initWithFrame:frame]; 201 | if (self) { 202 | 203 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; 204 | self.frame = keyWindow.bounds; 205 | 206 | 207 | UIView *gesView = [[UIView alloc] initWithFrame:self.bounds]; 208 | gesView.backgroundColor = [UIColor clearColor]; 209 | [gesView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideSelf)]]; 210 | [self addSubview:gesView]; 211 | 212 | self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4]; 213 | 214 | [self addSubview:self.selectionTableView]; 215 | } 216 | return self; 217 | } 218 | 219 | 220 | #pragma mark - Public Method 221 | 222 | + (void)showWithItemsBlock:(ITtemsBlock)itemsBlock selectedBlock:(SelectedTodoBlock)selectedBlock{ 223 | 224 | WZSelectionView *selectionView = [[WZSelectionView alloc] initWithFrame:CGRectZero]; 225 | [selectionView showWithItemsBlock:itemsBlock selectedBlock:selectedBlock]; 226 | 227 | } 228 | 229 | - (void)showWithItemsBlock:(ITtemsBlock)itemsBlock selectedBlock:(SelectedTodoBlock)selectedBlock{ 230 | 231 | self.seletedBlock = selectedBlock; 232 | itemsBlock(self.items); 233 | 234 | NSAssert(self.items.count>0, @"You must implement the protcol With method - (void)addItemWithLabelText: imageName: shouldDismiss:In ITtemsBlock"); 235 | 236 | CGFloat tableViewHeight = (self.items.count + 1) * kSelectionCellHeight; 237 | 238 | if (tableViewHeight <= KSelectionViewMaxHeight) { 239 | self.selectionTableView.scrollEnabled = NO; 240 | }else{ 241 | self.selectionTableView.scrollEnabled = YES; 242 | } 243 | 244 | tableViewHeight = tableViewHeight > KSelectionViewMaxHeight ? KSelectionViewMaxHeight : tableViewHeight; 245 | self.selectionTableView.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width, tableViewHeight); 246 | 247 | 248 | UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow; 249 | [keyWindow addSubview:self]; 250 | 251 | self.hidden = NO; 252 | [UIView animateWithDuration:0.2 animations:^{ 253 | CGRect selectionTableViewFrame = self.selectionTableView.frame; 254 | selectionTableViewFrame.origin.y = [UIScreen mainScreen].bounds.size.height - tableViewHeight; 255 | self.selectionTableView.frame = selectionTableViewFrame; 256 | }]; 257 | 258 | } 259 | 260 | #pragma mark - Actions 261 | 262 | - (void)hideSelf{ 263 | 264 | [UIView animateWithDuration:0.2 animations:^{ 265 | self.backgroundColor = [UIColor colorWithWhite:0 alpha:0]; 266 | CGRect selectionTableViewFrame = self.selectionTableView.frame; 267 | selectionTableViewFrame.origin.y = [UIScreen mainScreen].bounds.size.height; 268 | self.selectionTableView.frame = selectionTableViewFrame; 269 | } completion:^(BOOL finished) { 270 | self.hidden = YES; 271 | [self removeFromSuperview]; 272 | }]; 273 | 274 | 275 | } 276 | 277 | #pragma mark - Getter 278 | 279 | - (WZSelectionItems *)items{ 280 | if (!_items) { 281 | _items = [[WZSelectionItems alloc] init]; 282 | } 283 | return _items; 284 | } 285 | 286 | 287 | - (UITableView *)selectionTableView{ 288 | 289 | if (!_selectionTableView) { 290 | _selectionTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; 291 | _selectionTableView.separatorStyle=UITableViewCellSeparatorStyleNone; 292 | _selectionTableView.dataSource=self; 293 | _selectionTableView.delegate=self; 294 | } 295 | return _selectionTableView; 296 | 297 | } 298 | 299 | 300 | #pragma mark - UITableViewDataSource 301 | 302 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 303 | return 2; 304 | } 305 | 306 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 307 | { 308 | switch (section) { 309 | case 0:{ 310 | return self.items.count; 311 | break; 312 | } 313 | case 1:{ 314 | return 1; 315 | break; 316 | } 317 | default: 318 | break; 319 | } 320 | 321 | return 0; 322 | } 323 | 324 | 325 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 326 | 327 | static NSString *WZSelectionCellID=@"WZSelectionCell"; 328 | static NSString *WZSelectionCancelCellID=@"WZSelectionCancelCell"; 329 | 330 | UITableViewCell *aCell; 331 | 332 | switch (indexPath.section) { 333 | case 0:{ 334 | WZSelectionCell *cell=[tableView dequeueReusableCellWithIdentifier:WZSelectionCellID]; 335 | if (cell==nil) { 336 | cell=[[WZSelectionCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:WZSelectionCellID]; 337 | } 338 | 339 | if (self.items.count > indexPath.row) { 340 | cell.infoDictionary = self.items.itemsArray[indexPath.row]; 341 | } 342 | aCell = cell; 343 | break; 344 | } 345 | 346 | case 1:{ 347 | WZSelectionCancelCell *cell=[tableView dequeueReusableCellWithIdentifier:WZSelectionCancelCellID]; 348 | if (cell==nil) { 349 | cell=[[WZSelectionCancelCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:WZSelectionCancelCellID]; 350 | } 351 | aCell = cell; 352 | } 353 | 354 | default: 355 | break; 356 | } 357 | 358 | if (!aCell) { 359 | aCell = [[UITableViewCell alloc] init]; 360 | } 361 | 362 | return aCell; 363 | 364 | } 365 | 366 | -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 367 | { 368 | return kSelectionCellHeight; 369 | } 370 | 371 | #pragma mark - UITableViewDelegate 372 | 373 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 374 | if (tableView == self.selectionTableView) { 375 | 376 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 377 | if (indexPath.section == 0) { 378 | self.seletedBlock(indexPath.row); 379 | if (self.items.itemsArray.count > indexPath.row) { 380 | BOOL shouldDismiss = [[self.items.itemsArray[indexPath.row] objectForKey:kSelectionViewShouldDismissKey] boolValue]; 381 | if (shouldDismiss) { 382 | [self hideSelf]; 383 | } 384 | } 385 | } else { 386 | [self hideSelf]; 387 | } 388 | 389 | } 390 | } 391 | 392 | 393 | 394 | @end 395 | -------------------------------------------------------------------------------- /SimpleSelectionView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleSelectionView 4 | // 5 | // Created by  Will on 16/2/16. 6 | // Copyright © 2016年  Will. 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 | -------------------------------------------------------------------------------- /SimpleSelectionViewTests/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SimpleSelectionViewTests/SimpleSelectionViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleSelectionViewTests.m 3 | // SimpleSelectionViewTests 4 | // 5 | // Created by  Will on 16/2/16. 6 | // Copyright © 2016年  Will. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SimpleSelectionViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SimpleSelectionViewTests 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 | -------------------------------------------------------------------------------- /SimpleSelectionViewUITests/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SimpleSelectionViewUITests/SimpleSelectionViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimpleSelectionViewUITests.m 3 | // SimpleSelectionViewUITests 4 | // 5 | // Created by  Will on 16/2/16. 6 | // Copyright © 2016年  Will. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SimpleSelectionViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SimpleSelectionViewUITests 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 | -------------------------------------------------------------------------------- /a.txt: -------------------------------------------------------------------------------- 1 | hahaha 2 | --------------------------------------------------------------------------------