├── ColloectionLayout.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ ├── jasnig.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── ColloectionLayout.xcscheme │ │ └── xcschememanagement.plist │ └── zeroj.xcuserdatad │ └── xcschemes │ ├── ColloectionLayout.xcscheme │ └── xcschememanagement.plist ├── ColloectionLayout ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CirCleLayout.swift ├── Info.plist ├── LineLayout.swift ├── ViewController.swift └── WaterFallLayout.swift ├── ColloectionLayoutTests ├── ColloectionLayoutTests.swift └── Info.plist ├── ColloectionLayoutUITests ├── ColloectionLayoutUITests.swift └── Info.plist ├── LICENSE └── README.md /ColloectionLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4B0A187D1D0E6CA6000CBA4C /* LineLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B0A187C1D0E6CA6000CBA4C /* LineLayout.swift */; }; 11 | 4B0F822A1D0D6EBC00FCA6A3 /* CirCleLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B0F82291D0D6EBC00FCA6A3 /* CirCleLayout.swift */; }; 12 | 4B10F56D1D0AAA4500226BFC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B10F56C1D0AAA4500226BFC /* AppDelegate.swift */; }; 13 | 4B10F56F1D0AAA4500226BFC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B10F56E1D0AAA4500226BFC /* ViewController.swift */; }; 14 | 4B10F5721D0AAA4500226BFC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B10F5701D0AAA4500226BFC /* Main.storyboard */; }; 15 | 4B10F5741D0AAA4500226BFC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4B10F5731D0AAA4500226BFC /* Assets.xcassets */; }; 16 | 4B10F5771D0AAA4500226BFC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4B10F5751D0AAA4500226BFC /* LaunchScreen.storyboard */; }; 17 | 4B10F5821D0AAA4500226BFC /* ColloectionLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B10F5811D0AAA4500226BFC /* ColloectionLayoutTests.swift */; }; 18 | 4B10F58D1D0AAA4500226BFC /* ColloectionLayoutUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B10F58C1D0AAA4500226BFC /* ColloectionLayoutUITests.swift */; }; 19 | 4B10F59B1D0C308100226BFC /* WaterFallLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B10F59A1D0C308100226BFC /* WaterFallLayout.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 4B10F57E1D0AAA4500226BFC /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 4B10F5611D0AAA4500226BFC /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 4B10F5681D0AAA4500226BFC; 28 | remoteInfo = ColloectionLayout; 29 | }; 30 | 4B10F5891D0AAA4500226BFC /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 4B10F5611D0AAA4500226BFC /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 4B10F5681D0AAA4500226BFC; 35 | remoteInfo = ColloectionLayout; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 4B0A187C1D0E6CA6000CBA4C /* LineLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LineLayout.swift; sourceTree = ""; }; 41 | 4B0F82291D0D6EBC00FCA6A3 /* CirCleLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CirCleLayout.swift; sourceTree = ""; }; 42 | 4B10F5691D0AAA4500226BFC /* ColloectionLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ColloectionLayout.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 4B10F56C1D0AAA4500226BFC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 44 | 4B10F56E1D0AAA4500226BFC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 45 | 4B10F5711D0AAA4500226BFC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 4B10F5731D0AAA4500226BFC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 4B10F5761D0AAA4500226BFC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 4B10F5781D0AAA4500226BFC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 4B10F57D1D0AAA4500226BFC /* ColloectionLayoutTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ColloectionLayoutTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 4B10F5811D0AAA4500226BFC /* ColloectionLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColloectionLayoutTests.swift; sourceTree = ""; }; 51 | 4B10F5831D0AAA4500226BFC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 4B10F5881D0AAA4500226BFC /* ColloectionLayoutUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ColloectionLayoutUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 4B10F58C1D0AAA4500226BFC /* ColloectionLayoutUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColloectionLayoutUITests.swift; sourceTree = ""; }; 54 | 4B10F58E1D0AAA4500226BFC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 4B10F59A1D0C308100226BFC /* WaterFallLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WaterFallLayout.swift; sourceTree = ""; }; 56 | /* End PBXFileReference section */ 57 | 58 | /* Begin PBXFrameworksBuildPhase section */ 59 | 4B10F5661D0AAA4500226BFC /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | 4B10F57A1D0AAA4500226BFC /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | 4B10F5851D0AAA4500226BFC /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | 4B10F5601D0AAA4500226BFC = { 84 | isa = PBXGroup; 85 | children = ( 86 | 4B10F56B1D0AAA4500226BFC /* ColloectionLayout */, 87 | 4B10F5801D0AAA4500226BFC /* ColloectionLayoutTests */, 88 | 4B10F58B1D0AAA4500226BFC /* ColloectionLayoutUITests */, 89 | 4B10F56A1D0AAA4500226BFC /* Products */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | 4B10F56A1D0AAA4500226BFC /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 4B10F5691D0AAA4500226BFC /* ColloectionLayout.app */, 97 | 4B10F57D1D0AAA4500226BFC /* ColloectionLayoutTests.xctest */, 98 | 4B10F5881D0AAA4500226BFC /* ColloectionLayoutUITests.xctest */, 99 | ); 100 | name = Products; 101 | sourceTree = ""; 102 | }; 103 | 4B10F56B1D0AAA4500226BFC /* ColloectionLayout */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 4B10F56C1D0AAA4500226BFC /* AppDelegate.swift */, 107 | 4B10F56E1D0AAA4500226BFC /* ViewController.swift */, 108 | 4B0A187C1D0E6CA6000CBA4C /* LineLayout.swift */, 109 | 4B10F59A1D0C308100226BFC /* WaterFallLayout.swift */, 110 | 4B0F82291D0D6EBC00FCA6A3 /* CirCleLayout.swift */, 111 | 4B10F5701D0AAA4500226BFC /* Main.storyboard */, 112 | 4B10F5731D0AAA4500226BFC /* Assets.xcassets */, 113 | 4B10F5751D0AAA4500226BFC /* LaunchScreen.storyboard */, 114 | 4B10F5781D0AAA4500226BFC /* Info.plist */, 115 | ); 116 | path = ColloectionLayout; 117 | sourceTree = ""; 118 | }; 119 | 4B10F5801D0AAA4500226BFC /* ColloectionLayoutTests */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | 4B10F5811D0AAA4500226BFC /* ColloectionLayoutTests.swift */, 123 | 4B10F5831D0AAA4500226BFC /* Info.plist */, 124 | ); 125 | path = ColloectionLayoutTests; 126 | sourceTree = ""; 127 | }; 128 | 4B10F58B1D0AAA4500226BFC /* ColloectionLayoutUITests */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 4B10F58C1D0AAA4500226BFC /* ColloectionLayoutUITests.swift */, 132 | 4B10F58E1D0AAA4500226BFC /* Info.plist */, 133 | ); 134 | path = ColloectionLayoutUITests; 135 | sourceTree = ""; 136 | }; 137 | /* End PBXGroup section */ 138 | 139 | /* Begin PBXNativeTarget section */ 140 | 4B10F5681D0AAA4500226BFC /* ColloectionLayout */ = { 141 | isa = PBXNativeTarget; 142 | buildConfigurationList = 4B10F5911D0AAA4500226BFC /* Build configuration list for PBXNativeTarget "ColloectionLayout" */; 143 | buildPhases = ( 144 | 4B10F5651D0AAA4500226BFC /* Sources */, 145 | 4B10F5661D0AAA4500226BFC /* Frameworks */, 146 | 4B10F5671D0AAA4500226BFC /* Resources */, 147 | ); 148 | buildRules = ( 149 | ); 150 | dependencies = ( 151 | ); 152 | name = ColloectionLayout; 153 | productName = ColloectionLayout; 154 | productReference = 4B10F5691D0AAA4500226BFC /* ColloectionLayout.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | 4B10F57C1D0AAA4500226BFC /* ColloectionLayoutTests */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = 4B10F5941D0AAA4500226BFC /* Build configuration list for PBXNativeTarget "ColloectionLayoutTests" */; 160 | buildPhases = ( 161 | 4B10F5791D0AAA4500226BFC /* Sources */, 162 | 4B10F57A1D0AAA4500226BFC /* Frameworks */, 163 | 4B10F57B1D0AAA4500226BFC /* Resources */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | 4B10F57F1D0AAA4500226BFC /* PBXTargetDependency */, 169 | ); 170 | name = ColloectionLayoutTests; 171 | productName = ColloectionLayoutTests; 172 | productReference = 4B10F57D1D0AAA4500226BFC /* ColloectionLayoutTests.xctest */; 173 | productType = "com.apple.product-type.bundle.unit-test"; 174 | }; 175 | 4B10F5871D0AAA4500226BFC /* ColloectionLayoutUITests */ = { 176 | isa = PBXNativeTarget; 177 | buildConfigurationList = 4B10F5971D0AAA4500226BFC /* Build configuration list for PBXNativeTarget "ColloectionLayoutUITests" */; 178 | buildPhases = ( 179 | 4B10F5841D0AAA4500226BFC /* Sources */, 180 | 4B10F5851D0AAA4500226BFC /* Frameworks */, 181 | 4B10F5861D0AAA4500226BFC /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | 4B10F58A1D0AAA4500226BFC /* PBXTargetDependency */, 187 | ); 188 | name = ColloectionLayoutUITests; 189 | productName = ColloectionLayoutUITests; 190 | productReference = 4B10F5881D0AAA4500226BFC /* ColloectionLayoutUITests.xctest */; 191 | productType = "com.apple.product-type.bundle.ui-testing"; 192 | }; 193 | /* End PBXNativeTarget section */ 194 | 195 | /* Begin PBXProject section */ 196 | 4B10F5611D0AAA4500226BFC /* Project object */ = { 197 | isa = PBXProject; 198 | attributes = { 199 | LastSwiftUpdateCheck = 0730; 200 | LastUpgradeCheck = 0800; 201 | ORGANIZATIONNAME = ZeroJ; 202 | TargetAttributes = { 203 | 4B10F5681D0AAA4500226BFC = { 204 | CreatedOnToolsVersion = 7.3; 205 | DevelopmentTeam = 9G8PCT5S2D; 206 | DevelopmentTeamName = "晶 曾 (Personal Team)"; 207 | }; 208 | 4B10F57C1D0AAA4500226BFC = { 209 | CreatedOnToolsVersion = 7.3; 210 | TestTargetID = 4B10F5681D0AAA4500226BFC; 211 | }; 212 | 4B10F5871D0AAA4500226BFC = { 213 | CreatedOnToolsVersion = 7.3; 214 | TestTargetID = 4B10F5681D0AAA4500226BFC; 215 | }; 216 | }; 217 | }; 218 | buildConfigurationList = 4B10F5641D0AAA4500226BFC /* Build configuration list for PBXProject "ColloectionLayout" */; 219 | compatibilityVersion = "Xcode 3.2"; 220 | developmentRegion = English; 221 | hasScannedForEncodings = 0; 222 | knownRegions = ( 223 | en, 224 | Base, 225 | ); 226 | mainGroup = 4B10F5601D0AAA4500226BFC; 227 | productRefGroup = 4B10F56A1D0AAA4500226BFC /* Products */; 228 | projectDirPath = ""; 229 | projectRoot = ""; 230 | targets = ( 231 | 4B10F5681D0AAA4500226BFC /* ColloectionLayout */, 232 | 4B10F57C1D0AAA4500226BFC /* ColloectionLayoutTests */, 233 | 4B10F5871D0AAA4500226BFC /* ColloectionLayoutUITests */, 234 | ); 235 | }; 236 | /* End PBXProject section */ 237 | 238 | /* Begin PBXResourcesBuildPhase section */ 239 | 4B10F5671D0AAA4500226BFC /* Resources */ = { 240 | isa = PBXResourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | 4B10F5771D0AAA4500226BFC /* LaunchScreen.storyboard in Resources */, 244 | 4B10F5741D0AAA4500226BFC /* Assets.xcassets in Resources */, 245 | 4B10F5721D0AAA4500226BFC /* Main.storyboard in Resources */, 246 | ); 247 | runOnlyForDeploymentPostprocessing = 0; 248 | }; 249 | 4B10F57B1D0AAA4500226BFC /* Resources */ = { 250 | isa = PBXResourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | 4B10F5861D0AAA4500226BFC /* Resources */ = { 257 | isa = PBXResourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXResourcesBuildPhase section */ 264 | 265 | /* Begin PBXSourcesBuildPhase section */ 266 | 4B10F5651D0AAA4500226BFC /* Sources */ = { 267 | isa = PBXSourcesBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | 4B10F59B1D0C308100226BFC /* WaterFallLayout.swift in Sources */, 271 | 4B0F822A1D0D6EBC00FCA6A3 /* CirCleLayout.swift in Sources */, 272 | 4B10F56F1D0AAA4500226BFC /* ViewController.swift in Sources */, 273 | 4B0A187D1D0E6CA6000CBA4C /* LineLayout.swift in Sources */, 274 | 4B10F56D1D0AAA4500226BFC /* AppDelegate.swift in Sources */, 275 | ); 276 | runOnlyForDeploymentPostprocessing = 0; 277 | }; 278 | 4B10F5791D0AAA4500226BFC /* Sources */ = { 279 | isa = PBXSourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | 4B10F5821D0AAA4500226BFC /* ColloectionLayoutTests.swift in Sources */, 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | }; 286 | 4B10F5841D0AAA4500226BFC /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | 4B10F58D1D0AAA4500226BFC /* ColloectionLayoutUITests.swift in Sources */, 291 | ); 292 | runOnlyForDeploymentPostprocessing = 0; 293 | }; 294 | /* End PBXSourcesBuildPhase section */ 295 | 296 | /* Begin PBXTargetDependency section */ 297 | 4B10F57F1D0AAA4500226BFC /* PBXTargetDependency */ = { 298 | isa = PBXTargetDependency; 299 | target = 4B10F5681D0AAA4500226BFC /* ColloectionLayout */; 300 | targetProxy = 4B10F57E1D0AAA4500226BFC /* PBXContainerItemProxy */; 301 | }; 302 | 4B10F58A1D0AAA4500226BFC /* PBXTargetDependency */ = { 303 | isa = PBXTargetDependency; 304 | target = 4B10F5681D0AAA4500226BFC /* ColloectionLayout */; 305 | targetProxy = 4B10F5891D0AAA4500226BFC /* PBXContainerItemProxy */; 306 | }; 307 | /* End PBXTargetDependency section */ 308 | 309 | /* Begin PBXVariantGroup section */ 310 | 4B10F5701D0AAA4500226BFC /* Main.storyboard */ = { 311 | isa = PBXVariantGroup; 312 | children = ( 313 | 4B10F5711D0AAA4500226BFC /* Base */, 314 | ); 315 | name = Main.storyboard; 316 | sourceTree = ""; 317 | }; 318 | 4B10F5751D0AAA4500226BFC /* LaunchScreen.storyboard */ = { 319 | isa = PBXVariantGroup; 320 | children = ( 321 | 4B10F5761D0AAA4500226BFC /* Base */, 322 | ); 323 | name = LaunchScreen.storyboard; 324 | sourceTree = ""; 325 | }; 326 | /* End PBXVariantGroup section */ 327 | 328 | /* Begin XCBuildConfiguration section */ 329 | 4B10F58F1D0AAA4500226BFC /* Debug */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ALWAYS_SEARCH_USER_PATHS = NO; 333 | CLANG_ANALYZER_NONNULL = YES; 334 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 335 | CLANG_CXX_LIBRARY = "libc++"; 336 | CLANG_ENABLE_MODULES = YES; 337 | CLANG_ENABLE_OBJC_ARC = YES; 338 | CLANG_WARN_BOOL_CONVERSION = YES; 339 | CLANG_WARN_CONSTANT_CONVERSION = YES; 340 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 341 | CLANG_WARN_EMPTY_BODY = YES; 342 | CLANG_WARN_ENUM_CONVERSION = YES; 343 | CLANG_WARN_INT_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_UNREACHABLE_CODE = YES; 346 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 347 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 348 | COPY_PHASE_STRIP = NO; 349 | DEBUG_INFORMATION_FORMAT = dwarf; 350 | ENABLE_STRICT_OBJC_MSGSEND = YES; 351 | ENABLE_TESTABILITY = YES; 352 | GCC_C_LANGUAGE_STANDARD = gnu99; 353 | GCC_DYNAMIC_NO_PIC = NO; 354 | GCC_NO_COMMON_BLOCKS = YES; 355 | GCC_OPTIMIZATION_LEVEL = 0; 356 | GCC_PREPROCESSOR_DEFINITIONS = ( 357 | "DEBUG=1", 358 | "$(inherited)", 359 | ); 360 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 361 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 362 | GCC_WARN_UNDECLARED_SELECTOR = YES; 363 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 364 | GCC_WARN_UNUSED_FUNCTION = YES; 365 | GCC_WARN_UNUSED_VARIABLE = YES; 366 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 367 | MTL_ENABLE_DEBUG_INFO = YES; 368 | ONLY_ACTIVE_ARCH = YES; 369 | SDKROOT = iphoneos; 370 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 371 | TARGETED_DEVICE_FAMILY = "1,2"; 372 | }; 373 | name = Debug; 374 | }; 375 | 4B10F5901D0AAA4500226BFC /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ALWAYS_SEARCH_USER_PATHS = NO; 379 | CLANG_ANALYZER_NONNULL = YES; 380 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 381 | CLANG_CXX_LIBRARY = "libc++"; 382 | CLANG_ENABLE_MODULES = YES; 383 | CLANG_ENABLE_OBJC_ARC = YES; 384 | CLANG_WARN_BOOL_CONVERSION = YES; 385 | CLANG_WARN_CONSTANT_CONVERSION = YES; 386 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 387 | CLANG_WARN_EMPTY_BODY = YES; 388 | CLANG_WARN_ENUM_CONVERSION = YES; 389 | CLANG_WARN_INT_CONVERSION = YES; 390 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 391 | CLANG_WARN_UNREACHABLE_CODE = YES; 392 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 393 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 394 | COPY_PHASE_STRIP = NO; 395 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 396 | ENABLE_NS_ASSERTIONS = NO; 397 | ENABLE_STRICT_OBJC_MSGSEND = YES; 398 | GCC_C_LANGUAGE_STANDARD = gnu99; 399 | GCC_NO_COMMON_BLOCKS = YES; 400 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 401 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 402 | GCC_WARN_UNDECLARED_SELECTOR = YES; 403 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 404 | GCC_WARN_UNUSED_FUNCTION = YES; 405 | GCC_WARN_UNUSED_VARIABLE = YES; 406 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 407 | MTL_ENABLE_DEBUG_INFO = NO; 408 | SDKROOT = iphoneos; 409 | TARGETED_DEVICE_FAMILY = "1,2"; 410 | VALIDATE_PRODUCT = YES; 411 | }; 412 | name = Release; 413 | }; 414 | 4B10F5921D0AAA4500226BFC /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 418 | INFOPLIST_FILE = ColloectionLayout/Info.plist; 419 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 420 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 421 | PRODUCT_BUNDLE_IDENTIFIER = com.ZeroJ.ColloectionLayout; 422 | PRODUCT_NAME = "$(TARGET_NAME)"; 423 | SWIFT_VERSION = 3.0; 424 | }; 425 | name = Debug; 426 | }; 427 | 4B10F5931D0AAA4500226BFC /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 431 | INFOPLIST_FILE = ColloectionLayout/Info.plist; 432 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 433 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 434 | PRODUCT_BUNDLE_IDENTIFIER = com.ZeroJ.ColloectionLayout; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 437 | SWIFT_VERSION = 3.0; 438 | }; 439 | name = Release; 440 | }; 441 | 4B10F5951D0AAA4500226BFC /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | BUNDLE_LOADER = "$(TEST_HOST)"; 445 | INFOPLIST_FILE = ColloectionLayoutTests/Info.plist; 446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 447 | PRODUCT_BUNDLE_IDENTIFIER = com.ZeroJ.ColloectionLayoutTests; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ColloectionLayout.app/ColloectionLayout"; 450 | }; 451 | name = Debug; 452 | }; 453 | 4B10F5961D0AAA4500226BFC /* Release */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | BUNDLE_LOADER = "$(TEST_HOST)"; 457 | INFOPLIST_FILE = ColloectionLayoutTests/Info.plist; 458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 459 | PRODUCT_BUNDLE_IDENTIFIER = com.ZeroJ.ColloectionLayoutTests; 460 | PRODUCT_NAME = "$(TARGET_NAME)"; 461 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 462 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ColloectionLayout.app/ColloectionLayout"; 463 | }; 464 | name = Release; 465 | }; 466 | 4B10F5981D0AAA4500226BFC /* Debug */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | INFOPLIST_FILE = ColloectionLayoutUITests/Info.plist; 470 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 471 | PRODUCT_BUNDLE_IDENTIFIER = com.ZeroJ.ColloectionLayoutUITests; 472 | PRODUCT_NAME = "$(TARGET_NAME)"; 473 | TEST_TARGET_NAME = ColloectionLayout; 474 | }; 475 | name = Debug; 476 | }; 477 | 4B10F5991D0AAA4500226BFC /* Release */ = { 478 | isa = XCBuildConfiguration; 479 | buildSettings = { 480 | INFOPLIST_FILE = ColloectionLayoutUITests/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = com.ZeroJ.ColloectionLayoutUITests; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 485 | TEST_TARGET_NAME = ColloectionLayout; 486 | }; 487 | name = Release; 488 | }; 489 | /* End XCBuildConfiguration section */ 490 | 491 | /* Begin XCConfigurationList section */ 492 | 4B10F5641D0AAA4500226BFC /* Build configuration list for PBXProject "ColloectionLayout" */ = { 493 | isa = XCConfigurationList; 494 | buildConfigurations = ( 495 | 4B10F58F1D0AAA4500226BFC /* Debug */, 496 | 4B10F5901D0AAA4500226BFC /* Release */, 497 | ); 498 | defaultConfigurationIsVisible = 0; 499 | defaultConfigurationName = Release; 500 | }; 501 | 4B10F5911D0AAA4500226BFC /* Build configuration list for PBXNativeTarget "ColloectionLayout" */ = { 502 | isa = XCConfigurationList; 503 | buildConfigurations = ( 504 | 4B10F5921D0AAA4500226BFC /* Debug */, 505 | 4B10F5931D0AAA4500226BFC /* Release */, 506 | ); 507 | defaultConfigurationIsVisible = 0; 508 | defaultConfigurationName = Release; 509 | }; 510 | 4B10F5941D0AAA4500226BFC /* Build configuration list for PBXNativeTarget "ColloectionLayoutTests" */ = { 511 | isa = XCConfigurationList; 512 | buildConfigurations = ( 513 | 4B10F5951D0AAA4500226BFC /* Debug */, 514 | 4B10F5961D0AAA4500226BFC /* Release */, 515 | ); 516 | defaultConfigurationIsVisible = 0; 517 | defaultConfigurationName = Release; 518 | }; 519 | 4B10F5971D0AAA4500226BFC /* Build configuration list for PBXNativeTarget "ColloectionLayoutUITests" */ = { 520 | isa = XCConfigurationList; 521 | buildConfigurations = ( 522 | 4B10F5981D0AAA4500226BFC /* Debug */, 523 | 4B10F5991D0AAA4500226BFC /* Release */, 524 | ); 525 | defaultConfigurationIsVisible = 0; 526 | defaultConfigurationName = Release; 527 | }; 528 | /* End XCConfigurationList section */ 529 | }; 530 | rootObject = 4B10F5611D0AAA4500226BFC /* Project object */; 531 | } 532 | -------------------------------------------------------------------------------- /ColloectionLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ColloectionLayout.xcodeproj/xcuserdata/jasnig.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ColloectionLayout.xcodeproj/xcuserdata/jasnig.xcuserdatad/xcschemes/ColloectionLayout.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 | -------------------------------------------------------------------------------- /ColloectionLayout.xcodeproj/xcuserdata/jasnig.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ColloectionLayout.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4B10F5681D0AAA4500226BFC 16 | 17 | primary 18 | 19 | 20 | 4B10F57C1D0AAA4500226BFC 21 | 22 | primary 23 | 24 | 25 | 4B10F5871D0AAA4500226BFC 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ColloectionLayout.xcodeproj/xcuserdata/zeroj.xcuserdatad/xcschemes/ColloectionLayout.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 | -------------------------------------------------------------------------------- /ColloectionLayout.xcodeproj/xcuserdata/zeroj.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ColloectionLayout.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 4B10F5681D0AAA4500226BFC 16 | 17 | primary 18 | 19 | 20 | 4B10F57C1D0AAA4500226BFC 21 | 22 | primary 23 | 24 | 25 | 4B10F5871D0AAA4500226BFC 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ColloectionLayout/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ColloectionLayout 4 | // 5 | // Created by jasnig on 16/6/10. 6 | // Copyright © 2016年 ZeroJ. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ColloectionLayout/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /ColloectionLayout/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 | -------------------------------------------------------------------------------- /ColloectionLayout/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /ColloectionLayout/CirCleLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CirCleLayout.swift 3 | // ColloectionLayout 4 | // 5 | // Created by jasnig on 16/6/12. 6 | // Copyright © 2016年 ZeroJ. All rights reserved. 7 | // github: https://github.com/jasnig 8 | // 简书: http://www.jianshu.com/p/b84f4dd96d0c 9 | 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | 29 | import UIKit 30 | 31 | 32 | class CircleLayout: UICollectionViewLayout { 33 | private var layoutAttributes: [UICollectionViewLayoutAttributes] = [] 34 | // 圆心 35 | var center = CGPoint(x: 0.0, y: 0.0) 36 | // 圆半径 37 | var radius: CGFloat = 0.0 38 | var totalNum = 0 39 | override func prepare() { 40 | super.prepare() 41 | // 初始化需要的数据 42 | totalNum = collectionView!.numberOfItems(inSection: 0) 43 | // 每次计算前需要清零 44 | layoutAttributes = [] 45 | center = CGPoint(x: Double(collectionView!.bounds.width * 0.5), y: Double(collectionView!.bounds.height * 0.5)) 46 | radius = min(collectionView!.bounds.width, collectionView!.bounds.height) / 3.0 47 | 48 | var indexPath: IndexPath 49 | for index in 0.. Bool { 61 | return true 62 | } 63 | // Apple建议要重写这个方法, 因为某些情况下(delete insert...)系统可能需要调用这个方法来布局 64 | 65 | override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 66 | 67 | let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath) 68 | attributes.size = CGSize(width: 60.0, height: 60.0) 69 | // 当前cell的角度 70 | // 注意类型转换 71 | let angle = 2 * CGFloat(M_PI) * CGFloat(indexPath.row) / CGFloat(totalNum) 72 | // 一点点数学转换 73 | attributes.center = CGPoint(x: center.x + radius*cos(angle), y: center.y + radius*sin(angle)) 74 | return attributes 75 | } 76 | 77 | 78 | override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 79 | return layoutAttributes 80 | } 81 | 82 | override var collectionViewContentSize: CGSize { // change func to var 83 | return collectionView!.bounds.size 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /ColloectionLayout/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 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ColloectionLayout/LineLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LineLayout.swift 3 | // ColloectionLayout 4 | // 5 | // Created by jasnig on 16/6/13. 6 | // Copyright © 2016年 ZeroJ. All rights reserved. 7 | // github: https://github.com/jasnig 8 | // 简书: http://www.jianshu.com/p/b84f4dd96d0c 9 | 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | 29 | import UIKit 30 | 31 | 32 | class LineLayout: UICollectionViewFlowLayout { 33 | // 用来缓存布局 34 | private var layoutAttributes: [UICollectionViewLayoutAttributes] = [] 35 | override func prepare() { 36 | super.prepare() 37 | scrollDirection = .horizontal 38 | 39 | } 40 | 41 | override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 42 | layoutAttributes = [] 43 | let superLayoutAttributes = super.layoutAttributesForElements(in: rect)! 44 | 45 | let collectionViewCenterX = collectionView!.bounds.width * 0.5 46 | 47 | superLayoutAttributes.forEach { (attributes) in 48 | // 消除警告 49 | /** 50 | This is likely occurring because the flow layout subclass ColloectionLayout.LineLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them 51 | */ 52 | let copyLayout = attributes.copy() as! UICollectionViewLayoutAttributes 53 | // 和中心点的横向距离差 54 | let deltaX = abs(collectionViewCenterX - (copyLayout.center.x - collectionView!.contentOffset.x)) 55 | // 计算屏幕内的cell的transform 56 | if deltaX < collectionView!.bounds.width { 57 | let scale = 1.0 - deltaX / collectionViewCenterX 58 | copyLayout.transform = CGAffineTransform(scaleX: scale, y: scale) 59 | } 60 | 61 | layoutAttributes.append(copyLayout) 62 | } 63 | return layoutAttributes 64 | } 65 | /** 返回true将会标记collectionView的data为 'dirty' 66 | * collectionView检测到 'dirty'标记时会在下一个周期中更新布局 67 | * 滚动的时候实时更新布局 68 | */ 69 | override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { 70 | return true 71 | } 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /ColloectionLayout/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ColloectionLayout 4 | // 5 | // Created by jasnig on 16/6/10. 6 | // Copyright © 2016年 ZeroJ. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | class ViewController: UICollectionViewController { 13 | var cellCount = 50 14 | 15 | public lazy var cellHeight:[CGFloat] = { //changed private to public 16 | var arr:[CGFloat] = [] 17 | for _ in 0.. CGFloat { 66 | return cellHeight[indexPath.row] 67 | } 68 | } 69 | 70 | extension ViewController { 71 | override func numberOfSections(in collectionView: UICollectionView) -> Int { 72 | return 1 73 | } 74 | 75 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 76 | return cellCount 77 | } 78 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 79 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellID", for: indexPath) 80 | return cell 81 | } 82 | 83 | override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 84 | if indexPath.row % 2 == 0 {//偶数 85 | cellCount -= 1 86 | cellHeight.remove(at: indexPath.row) 87 | collectionView.performBatchUpdates({ 88 | collectionView.deleteItems(at: [indexPath]) 89 | }, completion: nil) 90 | } else { 91 | cellCount += 1 92 | cellHeight.append(CGFloat(arc4random() % 150 + 40)) 93 | 94 | collectionView.performBatchUpdates({ 95 | collectionView.insertItems(at: [indexPath]) 96 | }, completion: nil) 97 | } 98 | } 99 | 100 | 101 | } 102 | 103 | -------------------------------------------------------------------------------- /ColloectionLayout/WaterFallLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WaterFallLayout.swift 3 | // ColloectionLayout 4 | // 5 | // Created by jasnig on 16/6/11. 6 | // Copyright © 2016年 ZeroJ. All rights reserved. 7 | // github: https://github.com/jasnig 8 | // 简书: http://www.jianshu.com/users/fb31a3d1ec30/latest_articles 9 | 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | 29 | // 30 | 31 | import UIKit 32 | 33 | protocol WaterFallLayoutDelegate: NSObjectProtocol { 34 | // 用来设置每一个cell的高度 35 | func heightForItemAtIndexPath(indexPath: IndexPath) -> CGFloat 36 | } 37 | 38 | class WaterFallLayout: UICollectionViewLayout { 39 | /// 共有多少列 40 | var numberOfColums = 0 { 41 | didSet { 42 | // 初始化为0 43 | for _ in 0.. UICollectionViewLayoutAttributes? { 73 | return layoutAttributes[indexPath.row] 74 | 75 | } 76 | 77 | // 必须重写这个方法来返回计算好的LayoutAttributes 78 | override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 79 | // 返回计算好的layoutAttributes 80 | return layoutAttributes 81 | } 82 | 83 | // 返回collectionView的ContentSize -> 滚动范围 84 | //changed this -> override func collectionViewContentSize() -> CGSize to this-> 85 | override var collectionViewContentSize: CGSize { 86 | let maxY = maxYOfColums.max()! 87 | return CGSize(width: 0.0, height: maxY) 88 | } 89 | 90 | // 当collectionView的bounds(滚动, 或者frame变化)发生改变的时候就会调用这个方法 91 | override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { 92 | // 旋转屏幕后刷新视图 93 | return newBounds.width != oldScreenWidth 94 | 95 | } 96 | // 计算所有的UICollectionViewLayoutAttributes 97 | func computeLayoutAttributes() -> [UICollectionViewLayoutAttributes] { 98 | let totalNums = collectionView!.numberOfItems(inSection: 0) 99 | let width = (collectionView!.bounds.width - itemSpace * CGFloat(numberOfColums + 1)) / CGFloat(numberOfColums) 100 | 101 | var x: CGFloat 102 | var y: CGFloat 103 | var height: CGFloat 104 | var currentColum: Int 105 | var indexPath: IndexPath 106 | var attributesArr: [UICollectionViewLayoutAttributes] = [] 107 | 108 | guard let unwapDelegate = delegate else { 109 | assert(false, "需要设置代理") 110 | return attributesArr 111 | } 112 | 113 | for index in 0.. 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 | -------------------------------------------------------------------------------- /ColloectionLayoutUITests/ColloectionLayoutUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColloectionLayoutUITests.swift 3 | // ColloectionLayoutUITests 4 | // 5 | // Created by jasnig on 16/6/10. 6 | // Copyright © 2016年 ZeroJ. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class ColloectionLayoutUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // 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. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ColloectionLayoutUITests/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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 ZeroJ 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 | # CollectionViewLayout 2 | 自定义collectionViewLayout, 里面提供的布局可以直接拿来使用 3 | 4 | 5 | ![line.gif](http://upload-images.jianshu.io/upload_images/1271831-5849bd6f6a41eeb6.gif?imageMogr2/auto-orient/strip) 6 | 7 | ![water.gif](http://upload-images.jianshu.io/upload_images/1271831-228519017143d91d.gif?imageMogr2/auto-orient/strip) 8 | 9 | 10 | ![circle.gif](http://upload-images.jianshu.io/upload_images/1271831-b7ea5ed206ffdadd.gif?imageMogr2/auto-orient/strip) 11 | 12 | 13 | ####如果对你有帮助,请随手给个star 14 | ####如果你在使用中遇到问题: 可以联系我QQ: 854136959 --------------------------------------------------------------------------------