├── .gitignore ├── Objc └── OCTCustomCollectionViewLayout │ ├── OCTCustomCollectionViewLayout.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── OCTCustomCollectionViewLayout │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── img_1.imageset │ │ ├── Contents.json │ │ └── img_1.jpg │ ├── img_10.imageset │ │ ├── Contents.json │ │ └── img_10.jpg │ ├── img_2.imageset │ │ ├── Contents.json │ │ └── img_2.jpg │ ├── img_3.imageset │ │ ├── Contents.json │ │ └── img_3.png │ ├── img_4.imageset │ │ ├── Contents.json │ │ └── img_4.jpg │ ├── img_5.imageset │ │ ├── Contents.json │ │ └── img_5.jpg │ ├── img_6.imageset │ │ ├── Contents.json │ │ └── img_6.jpg │ ├── img_7.imageset │ │ ├── Contents.json │ │ └── img_7.jpg │ ├── img_8.imageset │ │ ├── Contents.json │ │ └── img_8.jpg │ ├── img_9.imageset │ │ ├── Contents.json │ │ └── img_9.jpg │ └── logo.imageset │ │ ├── Contents.json │ │ └── octo_v23.png │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── OCTAppDelegate.h │ ├── OCTAppDelegate.m │ ├── OCTBaseCollectionViewLayout.h │ ├── OCTBaseCollectionViewLayout.m │ ├── OCTCollectionViewCell.h │ ├── OCTCollectionViewCell.m │ ├── OCTCollectionViewCell.xib │ ├── OCTGalleryLayout_v1.h │ ├── OCTGalleryLayout_v1.m │ ├── OCTGalleryLayout_v2.h │ ├── OCTGalleryLayout_v2.m │ ├── OCTMainViewController.h │ ├── OCTMainViewController.m │ └── main.m ├── README.md └── Swift └── OCTCustomCollectionViewLayout ├── OCTCustomCollectionViewLayout.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── dmytrobr.xcuserdatad │ └── xcschemes │ ├── OCTCustomCollectionViewLayout.xcscheme │ └── xcschememanagement.plist └── OCTCustomCollectionViewLayout ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json ├── Contents.json ├── img_1.imageset │ ├── Contents.json │ └── img_1.jpg ├── img_10.imageset │ ├── Contents.json │ └── img_10.jpg ├── img_2.imageset │ ├── Contents.json │ └── img_2.jpg ├── img_3.imageset │ ├── Contents.json │ └── img_3.png ├── img_4.imageset │ ├── Contents.json │ └── img_4.jpg ├── img_5.imageset │ ├── Contents.json │ └── img_5.jpg ├── img_6.imageset │ ├── Contents.json │ └── img_6.jpg ├── img_7.imageset │ ├── Contents.json │ └── img_7.jpg ├── img_8.imageset │ ├── Contents.json │ └── img_8.jpg ├── img_9.imageset │ ├── Contents.json │ └── img_9.jpg └── logo.imageset │ ├── Contents.json │ └── octo_v23.png ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── OCTAppDelegate.swift ├── OCTBaseCollectionViewLayout.swift ├── OCTCollectionViewCell.swift ├── OCTCollectionViewCell.xib ├── OCTGalleryLayout_v1.swift ├── OCTGalleryLayout_v2.swift └── OCTMainViewController.swift /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | .xcodeproj/* 21 | !*.xcodeproj/*.pbxproj 22 | !*.xcodeproj/xcshareddata 23 | 24 | Pods 25 | .idea 26 | 27 | pkg/* 28 | 29 | Pods/* 30 | 31 | *.dSYM.zip 32 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 40EF5DC81E9430C500C14DC0 /* OCTCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 40EF5DC71E9430C500C14DC0 /* OCTCollectionViewCell.xib */; }; 11 | 40EF5DCB1E9430D200C14DC0 /* OCTCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 40EF5DCA1E9430D200C14DC0 /* OCTCollectionViewCell.m */; }; 12 | AECBCD881E9287D600510A56 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AECBCD871E9287D600510A56 /* main.m */; }; 13 | AECBCD8B1E9287D600510A56 /* OCTAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AECBCD8A1E9287D600510A56 /* OCTAppDelegate.m */; }; 14 | AECBCD8E1E9287D600510A56 /* OCTMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AECBCD8D1E9287D600510A56 /* OCTMainViewController.m */; }; 15 | AECBCD911E9287D600510A56 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AECBCD8F1E9287D600510A56 /* Main.storyboard */; }; 16 | AECBCD931E9287D600510A56 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AECBCD921E9287D600510A56 /* Assets.xcassets */; }; 17 | AECBCD961E9287D600510A56 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AECBCD941E9287D600510A56 /* LaunchScreen.storyboard */; }; 18 | AECBCD9F1E9289B000510A56 /* OCTBaseCollectionViewLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = AECBCD9E1E9289B000510A56 /* OCTBaseCollectionViewLayout.m */; }; 19 | AECBCDA21E9289BC00510A56 /* OCTGalleryLayout_v1.m in Sources */ = {isa = PBXBuildFile; fileRef = AECBCDA11E9289BC00510A56 /* OCTGalleryLayout_v1.m */; }; 20 | AECBCDA51E9289C600510A56 /* OCTGalleryLayout_v2.m in Sources */ = {isa = PBXBuildFile; fileRef = AECBCDA41E9289C600510A56 /* OCTGalleryLayout_v2.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 40EF5DC71E9430C500C14DC0 /* OCTCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OCTCollectionViewCell.xib; sourceTree = ""; }; 25 | 40EF5DC91E9430D200C14DC0 /* OCTCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCTCollectionViewCell.h; sourceTree = ""; }; 26 | 40EF5DCA1E9430D200C14DC0 /* OCTCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCTCollectionViewCell.m; sourceTree = ""; }; 27 | AECBCD831E9287D600510A56 /* OCTCustomCollectionViewLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OCTCustomCollectionViewLayout.app; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | AECBCD871E9287D600510A56 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29 | AECBCD891E9287D600510A56 /* OCTAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OCTAppDelegate.h; sourceTree = ""; }; 30 | AECBCD8A1E9287D600510A56 /* OCTAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OCTAppDelegate.m; sourceTree = ""; }; 31 | AECBCD8C1E9287D600510A56 /* OCTMainViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OCTMainViewController.h; sourceTree = ""; }; 32 | AECBCD8D1E9287D600510A56 /* OCTMainViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OCTMainViewController.m; sourceTree = ""; }; 33 | AECBCD901E9287D600510A56 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 34 | AECBCD921E9287D600510A56 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 35 | AECBCD951E9287D600510A56 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 36 | AECBCD971E9287D600510A56 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 37 | AECBCD9D1E9289B000510A56 /* OCTBaseCollectionViewLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCTBaseCollectionViewLayout.h; sourceTree = ""; }; 38 | AECBCD9E1E9289B000510A56 /* OCTBaseCollectionViewLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCTBaseCollectionViewLayout.m; sourceTree = ""; }; 39 | AECBCDA01E9289BC00510A56 /* OCTGalleryLayout_v1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCTGalleryLayout_v1.h; sourceTree = ""; }; 40 | AECBCDA11E9289BC00510A56 /* OCTGalleryLayout_v1.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCTGalleryLayout_v1.m; sourceTree = ""; }; 41 | AECBCDA31E9289C600510A56 /* OCTGalleryLayout_v2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OCTGalleryLayout_v2.h; sourceTree = ""; }; 42 | AECBCDA41E9289C600510A56 /* OCTGalleryLayout_v2.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OCTGalleryLayout_v2.m; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | AECBCD801E9287D600510A56 /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXFrameworksBuildPhase section */ 54 | 55 | /* Begin PBXGroup section */ 56 | 40EF5DCC1E9430E700C14DC0 /* Layouts */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | AECBCD9D1E9289B000510A56 /* OCTBaseCollectionViewLayout.h */, 60 | AECBCD9E1E9289B000510A56 /* OCTBaseCollectionViewLayout.m */, 61 | AECBCDA01E9289BC00510A56 /* OCTGalleryLayout_v1.h */, 62 | AECBCDA11E9289BC00510A56 /* OCTGalleryLayout_v1.m */, 63 | AECBCDA31E9289C600510A56 /* OCTGalleryLayout_v2.h */, 64 | AECBCDA41E9289C600510A56 /* OCTGalleryLayout_v2.m */, 65 | ); 66 | name = Layouts; 67 | sourceTree = ""; 68 | }; 69 | 40EF5DCD1E9430F600C14DC0 /* Cell */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 40EF5DC91E9430D200C14DC0 /* OCTCollectionViewCell.h */, 73 | 40EF5DCA1E9430D200C14DC0 /* OCTCollectionViewCell.m */, 74 | 40EF5DC71E9430C500C14DC0 /* OCTCollectionViewCell.xib */, 75 | ); 76 | name = Cell; 77 | sourceTree = ""; 78 | }; 79 | AECBCD7A1E9287D600510A56 = { 80 | isa = PBXGroup; 81 | children = ( 82 | AECBCD851E9287D600510A56 /* OCTCustomCollectionViewLayout */, 83 | AECBCD841E9287D600510A56 /* Products */, 84 | ); 85 | sourceTree = ""; 86 | }; 87 | AECBCD841E9287D600510A56 /* Products */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | AECBCD831E9287D600510A56 /* OCTCustomCollectionViewLayout.app */, 91 | ); 92 | name = Products; 93 | sourceTree = ""; 94 | }; 95 | AECBCD851E9287D600510A56 /* OCTCustomCollectionViewLayout */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 40EF5DCD1E9430F600C14DC0 /* Cell */, 99 | 40EF5DCC1E9430E700C14DC0 /* Layouts */, 100 | AECBCD891E9287D600510A56 /* OCTAppDelegate.h */, 101 | AECBCD8A1E9287D600510A56 /* OCTAppDelegate.m */, 102 | AECBCD8C1E9287D600510A56 /* OCTMainViewController.h */, 103 | AECBCD8D1E9287D600510A56 /* OCTMainViewController.m */, 104 | AECBCD8F1E9287D600510A56 /* Main.storyboard */, 105 | AECBCD921E9287D600510A56 /* Assets.xcassets */, 106 | AECBCD941E9287D600510A56 /* LaunchScreen.storyboard */, 107 | AECBCD971E9287D600510A56 /* Info.plist */, 108 | AECBCD861E9287D600510A56 /* Supporting Files */, 109 | ); 110 | path = OCTCustomCollectionViewLayout; 111 | sourceTree = ""; 112 | }; 113 | AECBCD861E9287D600510A56 /* Supporting Files */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | AECBCD871E9287D600510A56 /* main.m */, 117 | ); 118 | name = "Supporting Files"; 119 | sourceTree = ""; 120 | }; 121 | /* End PBXGroup section */ 122 | 123 | /* Begin PBXNativeTarget section */ 124 | AECBCD821E9287D600510A56 /* OCTCustomCollectionViewLayout */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = AECBCD9A1E9287D600510A56 /* Build configuration list for PBXNativeTarget "OCTCustomCollectionViewLayout" */; 127 | buildPhases = ( 128 | AECBCD7F1E9287D600510A56 /* Sources */, 129 | AECBCD801E9287D600510A56 /* Frameworks */, 130 | AECBCD811E9287D600510A56 /* Resources */, 131 | ); 132 | buildRules = ( 133 | ); 134 | dependencies = ( 135 | ); 136 | name = OCTCustomCollectionViewLayout; 137 | productName = OCTCustomCollectionViewLayout; 138 | productReference = AECBCD831E9287D600510A56 /* OCTCustomCollectionViewLayout.app */; 139 | productType = "com.apple.product-type.application"; 140 | }; 141 | /* End PBXNativeTarget section */ 142 | 143 | /* Begin PBXProject section */ 144 | AECBCD7B1E9287D600510A56 /* Project object */ = { 145 | isa = PBXProject; 146 | attributes = { 147 | LastUpgradeCheck = 0830; 148 | ORGANIZATIONNAME = dmitry.brovkin; 149 | TargetAttributes = { 150 | AECBCD821E9287D600510A56 = { 151 | CreatedOnToolsVersion = 8.3; 152 | ProvisioningStyle = Automatic; 153 | }; 154 | }; 155 | }; 156 | buildConfigurationList = AECBCD7E1E9287D600510A56 /* Build configuration list for PBXProject "OCTCustomCollectionViewLayout" */; 157 | compatibilityVersion = "Xcode 3.2"; 158 | developmentRegion = English; 159 | hasScannedForEncodings = 0; 160 | knownRegions = ( 161 | en, 162 | Base, 163 | ); 164 | mainGroup = AECBCD7A1E9287D600510A56; 165 | productRefGroup = AECBCD841E9287D600510A56 /* Products */; 166 | projectDirPath = ""; 167 | projectRoot = ""; 168 | targets = ( 169 | AECBCD821E9287D600510A56 /* OCTCustomCollectionViewLayout */, 170 | ); 171 | }; 172 | /* End PBXProject section */ 173 | 174 | /* Begin PBXResourcesBuildPhase section */ 175 | AECBCD811E9287D600510A56 /* Resources */ = { 176 | isa = PBXResourcesBuildPhase; 177 | buildActionMask = 2147483647; 178 | files = ( 179 | AECBCD961E9287D600510A56 /* LaunchScreen.storyboard in Resources */, 180 | AECBCD931E9287D600510A56 /* Assets.xcassets in Resources */, 181 | AECBCD911E9287D600510A56 /* Main.storyboard in Resources */, 182 | 40EF5DC81E9430C500C14DC0 /* OCTCollectionViewCell.xib in Resources */, 183 | ); 184 | runOnlyForDeploymentPostprocessing = 0; 185 | }; 186 | /* End PBXResourcesBuildPhase section */ 187 | 188 | /* Begin PBXSourcesBuildPhase section */ 189 | AECBCD7F1E9287D600510A56 /* Sources */ = { 190 | isa = PBXSourcesBuildPhase; 191 | buildActionMask = 2147483647; 192 | files = ( 193 | AECBCDA51E9289C600510A56 /* OCTGalleryLayout_v2.m in Sources */, 194 | AECBCD8E1E9287D600510A56 /* OCTMainViewController.m in Sources */, 195 | AECBCD8B1E9287D600510A56 /* OCTAppDelegate.m in Sources */, 196 | 40EF5DCB1E9430D200C14DC0 /* OCTCollectionViewCell.m in Sources */, 197 | AECBCD9F1E9289B000510A56 /* OCTBaseCollectionViewLayout.m in Sources */, 198 | AECBCD881E9287D600510A56 /* main.m in Sources */, 199 | AECBCDA21E9289BC00510A56 /* OCTGalleryLayout_v1.m in Sources */, 200 | ); 201 | runOnlyForDeploymentPostprocessing = 0; 202 | }; 203 | /* End PBXSourcesBuildPhase section */ 204 | 205 | /* Begin PBXVariantGroup section */ 206 | AECBCD8F1E9287D600510A56 /* Main.storyboard */ = { 207 | isa = PBXVariantGroup; 208 | children = ( 209 | AECBCD901E9287D600510A56 /* Base */, 210 | ); 211 | name = Main.storyboard; 212 | sourceTree = ""; 213 | }; 214 | AECBCD941E9287D600510A56 /* LaunchScreen.storyboard */ = { 215 | isa = PBXVariantGroup; 216 | children = ( 217 | AECBCD951E9287D600510A56 /* Base */, 218 | ); 219 | name = LaunchScreen.storyboard; 220 | sourceTree = ""; 221 | }; 222 | /* End PBXVariantGroup section */ 223 | 224 | /* Begin XCBuildConfiguration section */ 225 | AECBCD981E9287D600510A56 /* Debug */ = { 226 | isa = XCBuildConfiguration; 227 | buildSettings = { 228 | ALWAYS_SEARCH_USER_PATHS = NO; 229 | CLANG_ANALYZER_NONNULL = YES; 230 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 231 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 232 | CLANG_CXX_LIBRARY = "libc++"; 233 | CLANG_ENABLE_MODULES = YES; 234 | CLANG_ENABLE_OBJC_ARC = YES; 235 | CLANG_WARN_BOOL_CONVERSION = YES; 236 | CLANG_WARN_CONSTANT_CONVERSION = YES; 237 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 238 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 239 | CLANG_WARN_EMPTY_BODY = YES; 240 | CLANG_WARN_ENUM_CONVERSION = YES; 241 | CLANG_WARN_INFINITE_RECURSION = YES; 242 | CLANG_WARN_INT_CONVERSION = YES; 243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 244 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 245 | CLANG_WARN_UNREACHABLE_CODE = YES; 246 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 247 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 248 | COPY_PHASE_STRIP = NO; 249 | DEBUG_INFORMATION_FORMAT = dwarf; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | ENABLE_TESTABILITY = YES; 252 | GCC_C_LANGUAGE_STANDARD = gnu99; 253 | GCC_DYNAMIC_NO_PIC = NO; 254 | GCC_NO_COMMON_BLOCKS = YES; 255 | GCC_OPTIMIZATION_LEVEL = 0; 256 | GCC_PREPROCESSOR_DEFINITIONS = ( 257 | "DEBUG=1", 258 | "$(inherited)", 259 | ); 260 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 261 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 262 | GCC_WARN_UNDECLARED_SELECTOR = YES; 263 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 264 | GCC_WARN_UNUSED_FUNCTION = YES; 265 | GCC_WARN_UNUSED_VARIABLE = YES; 266 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 267 | MTL_ENABLE_DEBUG_INFO = YES; 268 | ONLY_ACTIVE_ARCH = YES; 269 | SDKROOT = iphoneos; 270 | TARGETED_DEVICE_FAMILY = "1,2"; 271 | }; 272 | name = Debug; 273 | }; 274 | AECBCD991E9287D600510A56 /* Release */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | ALWAYS_SEARCH_USER_PATHS = NO; 278 | CLANG_ANALYZER_NONNULL = YES; 279 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 280 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 281 | CLANG_CXX_LIBRARY = "libc++"; 282 | CLANG_ENABLE_MODULES = YES; 283 | CLANG_ENABLE_OBJC_ARC = YES; 284 | CLANG_WARN_BOOL_CONVERSION = YES; 285 | CLANG_WARN_CONSTANT_CONVERSION = YES; 286 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 287 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 288 | CLANG_WARN_EMPTY_BODY = YES; 289 | CLANG_WARN_ENUM_CONVERSION = YES; 290 | CLANG_WARN_INFINITE_RECURSION = YES; 291 | CLANG_WARN_INT_CONVERSION = YES; 292 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 293 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 294 | CLANG_WARN_UNREACHABLE_CODE = YES; 295 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 296 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 297 | COPY_PHASE_STRIP = NO; 298 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 299 | ENABLE_NS_ASSERTIONS = NO; 300 | ENABLE_STRICT_OBJC_MSGSEND = YES; 301 | GCC_C_LANGUAGE_STANDARD = gnu99; 302 | GCC_NO_COMMON_BLOCKS = YES; 303 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 304 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 305 | GCC_WARN_UNDECLARED_SELECTOR = YES; 306 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 307 | GCC_WARN_UNUSED_FUNCTION = YES; 308 | GCC_WARN_UNUSED_VARIABLE = YES; 309 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 310 | MTL_ENABLE_DEBUG_INFO = NO; 311 | SDKROOT = iphoneos; 312 | TARGETED_DEVICE_FAMILY = "1,2"; 313 | VALIDATE_PRODUCT = YES; 314 | }; 315 | name = Release; 316 | }; 317 | AECBCD9B1E9287D600510A56 /* Debug */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 321 | INFOPLIST_FILE = OCTCustomCollectionViewLayout/Info.plist; 322 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 323 | PRODUCT_BUNDLE_IDENTIFIER = Octodev.OCTCustomCollectionViewLayout; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | }; 326 | name = Debug; 327 | }; 328 | AECBCD9C1E9287D600510A56 /* Release */ = { 329 | isa = XCBuildConfiguration; 330 | buildSettings = { 331 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 332 | INFOPLIST_FILE = OCTCustomCollectionViewLayout/Info.plist; 333 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 334 | PRODUCT_BUNDLE_IDENTIFIER = Octodev.OCTCustomCollectionViewLayout; 335 | PRODUCT_NAME = "$(TARGET_NAME)"; 336 | }; 337 | name = Release; 338 | }; 339 | /* End XCBuildConfiguration section */ 340 | 341 | /* Begin XCConfigurationList section */ 342 | AECBCD7E1E9287D600510A56 /* Build configuration list for PBXProject "OCTCustomCollectionViewLayout" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | AECBCD981E9287D600510A56 /* Debug */, 346 | AECBCD991E9287D600510A56 /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | AECBCD9A1E9287D600510A56 /* Build configuration list for PBXNativeTarget "OCTCustomCollectionViewLayout" */ = { 352 | isa = XCConfigurationList; 353 | buildConfigurations = ( 354 | AECBCD9B1E9287D600510A56 /* Debug */, 355 | AECBCD9C1E9287D600510A56 /* Release */, 356 | ); 357 | defaultConfigurationIsVisible = 0; 358 | defaultConfigurationName = Release; 359 | }; 360 | /* End XCConfigurationList section */ 361 | }; 362 | rootObject = AECBCD7B1E9287D600510A56 /* Project object */; 363 | } 364 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_1.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_1.imageset/img_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_1.imageset/img_1.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_10.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_10.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_10.imageset/img_10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_10.imageset/img_10.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_2.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_2.imageset/img_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_2.imageset/img_2.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_3.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_3.imageset/img_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_3.imageset/img_3.png -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_4.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_4.imageset/img_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_4.imageset/img_4.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_5.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_5.imageset/img_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_5.imageset/img_5.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_6.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_6.imageset/img_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_6.imageset/img_6.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_7.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_7.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_7.imageset/img_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_7.imageset/img_7.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_8.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_8.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_8.imageset/img_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_8.imageset/img_8.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_9.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_9.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_9.imageset/img_9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_9.imageset/img_9.jpg -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/logo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "octo_v23.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/logo.imageset/octo_v23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/logo.imageset/octo_v23.png -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/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 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OCTAppDelegate: UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTAppDelegate.h" 10 | 11 | @implementation OCTAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 14 | return YES; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTBaseCollectionViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCTBaseCollectionViewLayout.h 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OCTBaseCollectionViewLayout : UICollectionViewLayout 12 | 13 | @property (nonatomic, readonly) NSInteger totalItemsInSection; 14 | @property (nonatomic, readonly) UIEdgeInsets contentInsets; 15 | 16 | @property (nonatomic, assign) NSInteger totalColumns; 17 | @property (nonatomic, assign) CGFloat interItemsSpacing; 18 | 19 | //These methods should be overriden by inheritor 20 | - (NSInteger)columnIndexForItemAtIndexPath:(NSIndexPath *)indexPath; 21 | - (CGRect)calculateItemFrameAtIndexPath:(NSIndexPath *)indexPath columnIndex:(NSInteger)columnIndex columnYoffset:(CGFloat)columnYoffset; 22 | - (void)calculateItemsSize; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTBaseCollectionViewLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCTBaseCollectionViewLayout.m 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTBaseCollectionViewLayout.h" 10 | 11 | @implementation OCTBaseCollectionViewLayout 12 | { 13 | NSMutableDictionary * _layoutMap; 14 | NSMutableArray *_columnsYoffset; 15 | CGSize _contentSize; 16 | } 17 | 18 | #pragma mark Init 19 | 20 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 21 | self = [super initWithCoder:aDecoder]; 22 | 23 | if (self) { 24 | _layoutMap = [NSMutableDictionary new]; 25 | self.totalColumns = 0; 26 | self.interItemsSpacing = 8; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | #pragma mark Override getters 33 | 34 | - (UIEdgeInsets)contentInsets { 35 | return self.collectionView.contentInset; 36 | } 37 | 38 | #pragma mark Override methods 39 | 40 | - (CGSize)collectionViewContentSize { 41 | return _contentSize; 42 | } 43 | 44 | - (void)prepareLayout { 45 | [_layoutMap removeAllObjects]; 46 | _totalItemsInSection = [self.collectionView numberOfItemsInSection:0]; 47 | _columnsYoffset = [self initialDataForColumnsOffsetY]; 48 | 49 | if (_totalItemsInSection > 0 && self.totalColumns > 0) { 50 | [self calculateItemsSize]; 51 | 52 | NSInteger itemIndex = 0; 53 | CGFloat contentSizeHeight = 0; 54 | 55 | while (itemIndex < _totalItemsInSection) { 56 | NSIndexPath *targetIndexPath = [NSIndexPath indexPathForItem:itemIndex inSection:0]; 57 | NSInteger columnIndex = [self columnIndexForItemAtIndexPath:targetIndexPath]; 58 | 59 | CGRect attributeRect = [self calculateItemFrameAtIndexPath:targetIndexPath columnIndex:columnIndex columnYoffset:_columnsYoffset[columnIndex].integerValue]; 60 | UICollectionViewLayoutAttributes *targetLayoutAttributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:targetIndexPath]; 61 | targetLayoutAttributes.frame = attributeRect; 62 | 63 | contentSizeHeight = MAX(CGRectGetMaxY(attributeRect), contentSizeHeight); 64 | _columnsYoffset[columnIndex] = @(CGRectGetMaxY(attributeRect) + self.interItemsSpacing); 65 | _layoutMap[targetIndexPath] = targetLayoutAttributes; 66 | 67 | itemIndex += 1; 68 | } 69 | 70 | _contentSize = CGSizeMake(self.collectionView.bounds.size.width - self.contentInsets.left - self.contentInsets.right, 71 | contentSizeHeight); 72 | } 73 | } 74 | 75 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { 76 | NSMutableArray *layoutAttributesArray = [NSMutableArray new]; 77 | 78 | for (UICollectionViewLayoutAttributes *layoutAttributes in _layoutMap.allValues) { 79 | if (CGRectIntersectsRect(layoutAttributes.frame, rect)) { 80 | [layoutAttributesArray addObject:layoutAttributes]; 81 | } 82 | } 83 | 84 | return layoutAttributesArray; 85 | } 86 | 87 | - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath { 88 | return _layoutMap[indexPath]; 89 | } 90 | 91 | #pragma mark Abstract methods 92 | - (NSInteger)columnIndexForItemAtIndexPath:(NSIndexPath *)indexPath { 93 | return indexPath.item % self.totalItemsInSection; 94 | } 95 | 96 | - (CGRect)calculateItemFrameAtIndexPath:(NSIndexPath *)indexPath columnIndex:(NSInteger)columnIndex columnYoffset:(CGFloat)columnYoffset { 97 | return CGRectZero; 98 | } 99 | 100 | - (void)calculateItemsSize {} 101 | 102 | #pragma mark Private methods 103 | 104 | - (NSMutableArray *)initialDataForColumnsOffsetY { 105 | NSMutableArray *tempArray = [NSMutableArray new]; 106 | 107 | for (int i = 0; i < self.totalColumns; i++) { 108 | [tempArray addObject:@(0)]; 109 | } 110 | return tempArray; 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCTCollectionViewCell.h 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by fantom on 4/4/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OCTCollectionViewCell : UICollectionViewCell 12 | 13 | @property (weak, nonatomic) IBOutlet UIImageView *imgView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTCollectionViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCTCollectionViewCell.m 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by fantom on 4/4/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTCollectionViewCell.h" 10 | 11 | @implementation OCTCollectionViewCell 12 | 13 | - (void)awakeFromNib { 14 | [super awakeFromNib]; 15 | self.imgView.layer.cornerRadius = 8; 16 | self.imgView.clipsToBounds = YES; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTCollectionViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTGalleryLayout_v1.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCTBaseCollectionViewLayout_v1.h 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTBaseCollectionViewLayout.h" 10 | 11 | @interface OCTGalleryLayout_v1 : OCTBaseCollectionViewLayout 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTGalleryLayout_v1.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCTBaseCollectionViewLayout_v1.m 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTGalleryLayout_v1.h" 10 | 11 | static const NSInteger kReducedHeightColumnIndex = 1; 12 | static const CGFloat kItemHeightAspect = 2; 13 | 14 | @implementation OCTGalleryLayout_v1 15 | { 16 | CGSize _itemSize; 17 | NSMutableArray *_columnsXoffset; 18 | } 19 | 20 | #pragma mark Init 21 | 22 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 23 | self = [super initWithCoder:aDecoder]; 24 | 25 | if (self) { 26 | self.totalColumns = 3; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | #pragma mark Override Abstract methods 33 | 34 | - (NSInteger)columnIndexForItemAtIndexPath:(NSIndexPath *)indexPath { 35 | //If last item is single in row, we move it to reduced column, to make it looks nice 36 | NSInteger columnIndex = indexPath.item % self.totalColumns; 37 | return [self isLastItemSingleInRowForIndexPath:indexPath] ? kReducedHeightColumnIndex : columnIndex; 38 | } 39 | 40 | - (CGRect)calculateItemFrameAtIndexPath:(NSIndexPath *)indexPath columnIndex:(NSInteger)columnIndex columnYoffset:(CGFloat)columnYoffset { 41 | NSInteger rowIndex = indexPath.item / self.totalColumns; 42 | CGFloat halfItemHeight = (_itemSize.height - self.interItemsSpacing) / 2; 43 | 44 | //Resolving Item height 45 | CGFloat itemHeight = _itemSize.height; 46 | 47 | // By our logic, first and last items in reduced height column have height divided by 2. 48 | if ((rowIndex == 0 && columnIndex == kReducedHeightColumnIndex) || [self isLastItemSingleInRowForIndexPath:indexPath]) { 49 | itemHeight = halfItemHeight; 50 | } 51 | 52 | return CGRectMake(_columnsXoffset[columnIndex].floatValue, columnYoffset, _itemSize.width, itemHeight); 53 | } 54 | 55 | - (void)calculateItemsSize { 56 | CGFloat contentWidthWithoutIndents = self.collectionView.bounds.size.width - self.contentInsets.left - self.contentInsets.right; 57 | CGFloat itemWidth = (contentWidthWithoutIndents - (self.totalColumns - 1) * self.interItemsSpacing) / self.totalColumns; 58 | CGFloat itemHeight = itemWidth * kItemHeightAspect; 59 | 60 | _itemSize = CGSizeMake(itemWidth, itemHeight); 61 | 62 | // Calculating offsets by X for each column 63 | _columnsXoffset = [NSMutableArray new]; 64 | 65 | for (int columnIndex = 0; columnIndex < self.totalColumns; columnIndex++) { 66 | [_columnsXoffset addObject:@(columnIndex * (_itemSize.width + self.interItemsSpacing))]; 67 | } 68 | } 69 | 70 | - (NSString *)description { 71 | return @"Layout v1"; 72 | } 73 | 74 | #pragma mark Private methdos 75 | 76 | - (BOOL)isLastItemSingleInRowForIndexPath:(NSIndexPath *)indexPath { 77 | return indexPath.item == (self.totalItemsInSection - 1) && indexPath.item % self.totalColumns == 0; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTGalleryLayout_v2.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCTBaseCollectionViewLayout_v2.h 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTBaseCollectionViewLayout.h" 10 | 11 | @interface OCTGalleryLayout_v2 : OCTBaseCollectionViewLayout 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTGalleryLayout_v2.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCTBaseCollectionViewLayout_v2.m 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTGalleryLayout_v2.h" 10 | 11 | static const CGFloat kSideItemWidthCoef = 0.3; 12 | static const CGFloat kSideItemHeightAspect = 1; 13 | static const NSInteger kNumberOfSideItems = 3; 14 | 15 | @implementation OCTGalleryLayout_v2 16 | { 17 | CGSize _mainItemSize; 18 | CGSize _sideItemSize; 19 | NSArray *_columnsXoffset; 20 | } 21 | 22 | #pragma mark Init 23 | 24 | - (instancetype)initWithCoder:(NSCoder *)aDecoder { 25 | self = [super initWithCoder:aDecoder]; 26 | 27 | if (self) { 28 | self.totalColumns = 2; 29 | } 30 | 31 | return self; 32 | } 33 | 34 | #pragma mark Override Abstract methods 35 | 36 | - (NSInteger)columnIndexForItemAtIndexPath:(NSIndexPath *)indexPath { 37 | NSInteger totalItemsInRow = kNumberOfSideItems + 1; 38 | NSInteger columnIndex = indexPath.item % totalItemsInRow; 39 | NSInteger columnIndexLimit = self.totalColumns - 1; 40 | 41 | return columnIndex > columnIndexLimit ? columnIndexLimit : columnIndex; 42 | } 43 | 44 | - (CGRect)calculateItemFrameAtIndexPath:(NSIndexPath *)indexPath columnIndex:(NSInteger)columnIndex columnYoffset:(CGFloat)columnYoffset { 45 | CGSize size = columnIndex == 0 ? _mainItemSize : _sideItemSize; 46 | return CGRectMake(_columnsXoffset[columnIndex].floatValue, columnYoffset, size.width, size.height); 47 | } 48 | 49 | - (void)calculateItemsSize { 50 | CGFloat contentWidthWithoutIndents = self.collectionView.bounds.size.width - self.contentInsets.left - self.contentInsets.right; 51 | CGFloat resolvedContentWidth = contentWidthWithoutIndents - self.interItemsSpacing; 52 | 53 | // We need to calculate side item size first, in order to calculate main item height 54 | CGFloat sideItemWidth = resolvedContentWidth * kSideItemWidthCoef; 55 | CGFloat sideItemHeight = sideItemWidth * kSideItemHeightAspect; 56 | 57 | _sideItemSize = CGSizeMake(sideItemWidth, sideItemHeight); 58 | 59 | // Now we can calculate main item height 60 | CGFloat mainItemWidth = resolvedContentWidth - sideItemWidth; 61 | CGFloat mainItemHeight = sideItemHeight * kNumberOfSideItems + ((kNumberOfSideItems - 1) * self.interItemsSpacing); 62 | 63 | _mainItemSize = CGSizeMake(mainItemWidth, mainItemHeight); 64 | 65 | // Calculating offsets by X for each column 66 | _columnsXoffset = @[@(0), @(_mainItemSize.width + self.interItemsSpacing)]; 67 | } 68 | 69 | - (NSString *)description { 70 | return @"Layout v2"; 71 | } 72 | 73 | @end 74 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTMainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OCTMainViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTMainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import "OCTMainViewController.h" 10 | #import "OCTCollectionViewCell.h" 11 | 12 | static NSString *const kReuseCellID = @"reuseCellID"; 13 | static NSString *const kImgName = @"img_"; 14 | static const NSInteger kTotalImgs = 10; 15 | 16 | 17 | @interface OCTMainViewController () 18 | 19 | @property (weak, nonatomic) IBOutlet UICollectionView *collectionView; 20 | 21 | @end 22 | 23 | 24 | @implementation OCTMainViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | 29 | self.automaticallyAdjustsScrollViewInsets = NO; 30 | self.title = [self.collectionView.collectionViewLayout description]; 31 | 32 | self.collectionView.contentInset = UIEdgeInsetsMake(8, 8, 8, 8); 33 | [self.collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([OCTCollectionViewCell class]) bundle:nil] 34 | forCellWithReuseIdentifier:kReuseCellID]; 35 | } 36 | 37 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 38 | return 13; 39 | } 40 | 41 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 42 | int imgNumber = indexPath.item % kTotalImgs + 1; 43 | NSString *imageName = [NSString stringWithFormat:@"%@%d", kImgName, imgNumber]; 44 | 45 | OCTCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kReuseCellID forIndexPath:indexPath]; 46 | cell.imgView.image = [UIImage imageNamed:imageName]; 47 | 48 | return cell; 49 | } 50 | 51 | - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { 52 | [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; 53 | [self.collectionView.collectionViewLayout invalidateLayout]; 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /Objc/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "OCTAppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([OCTAppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CustomCollectionViewLayout 2 | 3 |   4 |

Expected result

5 | 6 | 7 |

Implementation

8 | Prease find full tutorial at the following link. 9 | In this tutorial, I'm going to show you, how to create a custom UICollectionView layout. 10 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 40EF5DC51E94254200C14DC0 /* OCTCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40EF5DC31E94254200C14DC0 /* OCTCollectionViewCell.swift */; }; 11 | 40EF5DC61E94254200C14DC0 /* OCTCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 40EF5DC41E94254200C14DC0 /* OCTCollectionViewCell.xib */; }; 12 | AE4AE4961E8E744E006E9489 /* OCTAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE4AE4951E8E744E006E9489 /* OCTAppDelegate.swift */; }; 13 | AE4AE4981E8E744E006E9489 /* OCTMainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE4AE4971E8E744E006E9489 /* OCTMainViewController.swift */; }; 14 | AE4AE49B1E8E744E006E9489 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AE4AE4991E8E744E006E9489 /* Main.storyboard */; }; 15 | AE4AE49D1E8E744E006E9489 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AE4AE49C1E8E744E006E9489 /* Assets.xcassets */; }; 16 | AE4AE4A01E8E744E006E9489 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AE4AE49E1E8E744E006E9489 /* LaunchScreen.storyboard */; }; 17 | AE4AE4A81E8E79A4006E9489 /* OCTGalleryLayout_v1.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE4AE4A71E8E79A4006E9489 /* OCTGalleryLayout_v1.swift */; }; 18 | AECBCD771E92655F00510A56 /* OCTGalleryLayout_v2.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECBCD761E92655F00510A56 /* OCTGalleryLayout_v2.swift */; }; 19 | AECBCD791E92689C00510A56 /* OCTBaseCollectionViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = AECBCD781E92689C00510A56 /* OCTBaseCollectionViewLayout.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 40EF5DC31E94254200C14DC0 /* OCTCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OCTCollectionViewCell.swift; sourceTree = ""; }; 24 | 40EF5DC41E94254200C14DC0 /* OCTCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = OCTCollectionViewCell.xib; sourceTree = ""; }; 25 | AE4AE4921E8E744E006E9489 /* OCTCustomCollectionViewLayout.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OCTCustomCollectionViewLayout.app; sourceTree = BUILT_PRODUCTS_DIR; }; 26 | AE4AE4951E8E744E006E9489 /* OCTAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OCTAppDelegate.swift; sourceTree = ""; }; 27 | AE4AE4971E8E744E006E9489 /* OCTMainViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OCTMainViewController.swift; sourceTree = ""; }; 28 | AE4AE49A1E8E744E006E9489 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 29 | AE4AE49C1E8E744E006E9489 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 30 | AE4AE49F1E8E744E006E9489 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 31 | AE4AE4A11E8E744E006E9489 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | AE4AE4A71E8E79A4006E9489 /* OCTGalleryLayout_v1.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OCTGalleryLayout_v1.swift; sourceTree = ""; }; 33 | AECBCD761E92655F00510A56 /* OCTGalleryLayout_v2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OCTGalleryLayout_v2.swift; sourceTree = ""; }; 34 | AECBCD781E92689C00510A56 /* OCTBaseCollectionViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OCTBaseCollectionViewLayout.swift; sourceTree = ""; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | AE4AE48F1E8E744E006E9489 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | /* End PBXFrameworksBuildPhase section */ 46 | 47 | /* Begin PBXGroup section */ 48 | AE4AE4891E8E744E006E9489 = { 49 | isa = PBXGroup; 50 | children = ( 51 | AE4AE4941E8E744E006E9489 /* OCTCustomCollectionViewLayout */, 52 | AE4AE4931E8E744E006E9489 /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | AE4AE4931E8E744E006E9489 /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | AE4AE4921E8E744E006E9489 /* OCTCustomCollectionViewLayout.app */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | AE4AE4941E8E744E006E9489 /* OCTCustomCollectionViewLayout */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | AE4AE4951E8E744E006E9489 /* OCTAppDelegate.swift */, 68 | AE4AE4971E8E744E006E9489 /* OCTMainViewController.swift */, 69 | AECBCD781E92689C00510A56 /* OCTBaseCollectionViewLayout.swift */, 70 | AE4AE4A71E8E79A4006E9489 /* OCTGalleryLayout_v1.swift */, 71 | AECBCD761E92655F00510A56 /* OCTGalleryLayout_v2.swift */, 72 | 40EF5DC31E94254200C14DC0 /* OCTCollectionViewCell.swift */, 73 | 40EF5DC41E94254200C14DC0 /* OCTCollectionViewCell.xib */, 74 | AE4AE4991E8E744E006E9489 /* Main.storyboard */, 75 | AE4AE49C1E8E744E006E9489 /* Assets.xcassets */, 76 | AE4AE49E1E8E744E006E9489 /* LaunchScreen.storyboard */, 77 | AE4AE4A11E8E744E006E9489 /* Info.plist */, 78 | ); 79 | path = OCTCustomCollectionViewLayout; 80 | sourceTree = ""; 81 | }; 82 | /* End PBXGroup section */ 83 | 84 | /* Begin PBXNativeTarget section */ 85 | AE4AE4911E8E744E006E9489 /* OCTCustomCollectionViewLayout */ = { 86 | isa = PBXNativeTarget; 87 | buildConfigurationList = AE4AE4A41E8E744E006E9489 /* Build configuration list for PBXNativeTarget "OCTCustomCollectionViewLayout" */; 88 | buildPhases = ( 89 | AE4AE48E1E8E744E006E9489 /* Sources */, 90 | AE4AE48F1E8E744E006E9489 /* Frameworks */, 91 | AE4AE4901E8E744E006E9489 /* Resources */, 92 | ); 93 | buildRules = ( 94 | ); 95 | dependencies = ( 96 | ); 97 | name = OCTCustomCollectionViewLayout; 98 | productName = OCTCustomCollectionViewLayout; 99 | productReference = AE4AE4921E8E744E006E9489 /* OCTCustomCollectionViewLayout.app */; 100 | productType = "com.apple.product-type.application"; 101 | }; 102 | /* End PBXNativeTarget section */ 103 | 104 | /* Begin PBXProject section */ 105 | AE4AE48A1E8E744E006E9489 /* Project object */ = { 106 | isa = PBXProject; 107 | attributes = { 108 | LastSwiftUpdateCheck = 0830; 109 | LastUpgradeCheck = 0830; 110 | ORGANIZATIONNAME = dmitry.brovkin; 111 | TargetAttributes = { 112 | AE4AE4911E8E744E006E9489 = { 113 | CreatedOnToolsVersion = 8.3; 114 | ProvisioningStyle = Automatic; 115 | }; 116 | }; 117 | }; 118 | buildConfigurationList = AE4AE48D1E8E744E006E9489 /* Build configuration list for PBXProject "OCTCustomCollectionViewLayout" */; 119 | compatibilityVersion = "Xcode 3.2"; 120 | developmentRegion = English; 121 | hasScannedForEncodings = 0; 122 | knownRegions = ( 123 | en, 124 | Base, 125 | ); 126 | mainGroup = AE4AE4891E8E744E006E9489; 127 | productRefGroup = AE4AE4931E8E744E006E9489 /* Products */; 128 | projectDirPath = ""; 129 | projectRoot = ""; 130 | targets = ( 131 | AE4AE4911E8E744E006E9489 /* OCTCustomCollectionViewLayout */, 132 | ); 133 | }; 134 | /* End PBXProject section */ 135 | 136 | /* Begin PBXResourcesBuildPhase section */ 137 | AE4AE4901E8E744E006E9489 /* Resources */ = { 138 | isa = PBXResourcesBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | AE4AE4A01E8E744E006E9489 /* LaunchScreen.storyboard in Resources */, 142 | AE4AE49D1E8E744E006E9489 /* Assets.xcassets in Resources */, 143 | AE4AE49B1E8E744E006E9489 /* Main.storyboard in Resources */, 144 | 40EF5DC61E94254200C14DC0 /* OCTCollectionViewCell.xib in Resources */, 145 | ); 146 | runOnlyForDeploymentPostprocessing = 0; 147 | }; 148 | /* End PBXResourcesBuildPhase section */ 149 | 150 | /* Begin PBXSourcesBuildPhase section */ 151 | AE4AE48E1E8E744E006E9489 /* Sources */ = { 152 | isa = PBXSourcesBuildPhase; 153 | buildActionMask = 2147483647; 154 | files = ( 155 | AE4AE4981E8E744E006E9489 /* OCTMainViewController.swift in Sources */, 156 | AE4AE4961E8E744E006E9489 /* OCTAppDelegate.swift in Sources */, 157 | AECBCD771E92655F00510A56 /* OCTGalleryLayout_v2.swift in Sources */, 158 | 40EF5DC51E94254200C14DC0 /* OCTCollectionViewCell.swift in Sources */, 159 | AECBCD791E92689C00510A56 /* OCTBaseCollectionViewLayout.swift in Sources */, 160 | AE4AE4A81E8E79A4006E9489 /* OCTGalleryLayout_v1.swift in Sources */, 161 | ); 162 | runOnlyForDeploymentPostprocessing = 0; 163 | }; 164 | /* End PBXSourcesBuildPhase section */ 165 | 166 | /* Begin PBXVariantGroup section */ 167 | AE4AE4991E8E744E006E9489 /* Main.storyboard */ = { 168 | isa = PBXVariantGroup; 169 | children = ( 170 | AE4AE49A1E8E744E006E9489 /* Base */, 171 | ); 172 | name = Main.storyboard; 173 | sourceTree = ""; 174 | }; 175 | AE4AE49E1E8E744E006E9489 /* LaunchScreen.storyboard */ = { 176 | isa = PBXVariantGroup; 177 | children = ( 178 | AE4AE49F1E8E744E006E9489 /* Base */, 179 | ); 180 | name = LaunchScreen.storyboard; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXVariantGroup section */ 184 | 185 | /* Begin XCBuildConfiguration section */ 186 | AE4AE4A21E8E744E006E9489 /* Debug */ = { 187 | isa = XCBuildConfiguration; 188 | buildSettings = { 189 | ALWAYS_SEARCH_USER_PATHS = NO; 190 | CLANG_ANALYZER_NONNULL = YES; 191 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 192 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 193 | CLANG_CXX_LIBRARY = "libc++"; 194 | CLANG_ENABLE_MODULES = YES; 195 | CLANG_ENABLE_OBJC_ARC = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_CONSTANT_CONVERSION = YES; 198 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 199 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 200 | CLANG_WARN_EMPTY_BODY = YES; 201 | CLANG_WARN_ENUM_CONVERSION = YES; 202 | CLANG_WARN_INFINITE_RECURSION = YES; 203 | CLANG_WARN_INT_CONVERSION = YES; 204 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 205 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 206 | CLANG_WARN_UNREACHABLE_CODE = YES; 207 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 208 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 209 | COPY_PHASE_STRIP = NO; 210 | DEBUG_INFORMATION_FORMAT = dwarf; 211 | ENABLE_STRICT_OBJC_MSGSEND = YES; 212 | ENABLE_TESTABILITY = YES; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_NO_COMMON_BLOCKS = YES; 216 | GCC_OPTIMIZATION_LEVEL = 0; 217 | GCC_PREPROCESSOR_DEFINITIONS = ( 218 | "DEBUG=1", 219 | "$(inherited)", 220 | ); 221 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 222 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 223 | GCC_WARN_UNDECLARED_SELECTOR = YES; 224 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 225 | GCC_WARN_UNUSED_FUNCTION = YES; 226 | GCC_WARN_UNUSED_VARIABLE = YES; 227 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 228 | MTL_ENABLE_DEBUG_INFO = YES; 229 | ONLY_ACTIVE_ARCH = YES; 230 | SDKROOT = iphoneos; 231 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 232 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 233 | TARGETED_DEVICE_FAMILY = "1,2"; 234 | }; 235 | name = Debug; 236 | }; 237 | AE4AE4A31E8E744E006E9489 /* Release */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | ALWAYS_SEARCH_USER_PATHS = NO; 241 | CLANG_ANALYZER_NONNULL = YES; 242 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 243 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 244 | CLANG_CXX_LIBRARY = "libc++"; 245 | CLANG_ENABLE_MODULES = YES; 246 | CLANG_ENABLE_OBJC_ARC = YES; 247 | CLANG_WARN_BOOL_CONVERSION = YES; 248 | CLANG_WARN_CONSTANT_CONVERSION = YES; 249 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 250 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 251 | CLANG_WARN_EMPTY_BODY = YES; 252 | CLANG_WARN_ENUM_CONVERSION = YES; 253 | CLANG_WARN_INFINITE_RECURSION = YES; 254 | CLANG_WARN_INT_CONVERSION = YES; 255 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 256 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 257 | CLANG_WARN_UNREACHABLE_CODE = YES; 258 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 259 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 260 | COPY_PHASE_STRIP = NO; 261 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 262 | ENABLE_NS_ASSERTIONS = NO; 263 | ENABLE_STRICT_OBJC_MSGSEND = YES; 264 | GCC_C_LANGUAGE_STANDARD = gnu99; 265 | GCC_NO_COMMON_BLOCKS = YES; 266 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 267 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 268 | GCC_WARN_UNDECLARED_SELECTOR = YES; 269 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 270 | GCC_WARN_UNUSED_FUNCTION = YES; 271 | GCC_WARN_UNUSED_VARIABLE = YES; 272 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 273 | MTL_ENABLE_DEBUG_INFO = NO; 274 | SDKROOT = iphoneos; 275 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 276 | TARGETED_DEVICE_FAMILY = "1,2"; 277 | VALIDATE_PRODUCT = YES; 278 | }; 279 | name = Release; 280 | }; 281 | AE4AE4A51E8E744E006E9489 /* Debug */ = { 282 | isa = XCBuildConfiguration; 283 | buildSettings = { 284 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 285 | INFOPLIST_FILE = OCTCustomCollectionViewLayout/Info.plist; 286 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 287 | PRODUCT_BUNDLE_IDENTIFIER = Octodev.OCTCustomCollectionViewLayout; 288 | PRODUCT_NAME = "$(TARGET_NAME)"; 289 | SWIFT_VERSION = 3.0; 290 | }; 291 | name = Debug; 292 | }; 293 | AE4AE4A61E8E744E006E9489 /* Release */ = { 294 | isa = XCBuildConfiguration; 295 | buildSettings = { 296 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 297 | INFOPLIST_FILE = OCTCustomCollectionViewLayout/Info.plist; 298 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 299 | PRODUCT_BUNDLE_IDENTIFIER = Octodev.OCTCustomCollectionViewLayout; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | SWIFT_VERSION = 3.0; 302 | }; 303 | name = Release; 304 | }; 305 | /* End XCBuildConfiguration section */ 306 | 307 | /* Begin XCConfigurationList section */ 308 | AE4AE48D1E8E744E006E9489 /* Build configuration list for PBXProject "OCTCustomCollectionViewLayout" */ = { 309 | isa = XCConfigurationList; 310 | buildConfigurations = ( 311 | AE4AE4A21E8E744E006E9489 /* Debug */, 312 | AE4AE4A31E8E744E006E9489 /* Release */, 313 | ); 314 | defaultConfigurationIsVisible = 0; 315 | defaultConfigurationName = Release; 316 | }; 317 | AE4AE4A41E8E744E006E9489 /* Build configuration list for PBXNativeTarget "OCTCustomCollectionViewLayout" */ = { 318 | isa = XCConfigurationList; 319 | buildConfigurations = ( 320 | AE4AE4A51E8E744E006E9489 /* Debug */, 321 | AE4AE4A61E8E744E006E9489 /* Release */, 322 | ); 323 | defaultConfigurationIsVisible = 0; 324 | defaultConfigurationName = Release; 325 | }; 326 | /* End XCConfigurationList section */ 327 | }; 328 | rootObject = AE4AE48A1E8E744E006E9489 /* Project object */; 329 | } 330 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout.xcodeproj/xcuserdata/dmytrobr.xcuserdatad/xcschemes/OCTCustomCollectionViewLayout.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 69 | 70 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout.xcodeproj/xcuserdata/dmytrobr.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OCTCustomCollectionViewLayout.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | AE4AE4911E8E744E006E9489 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_1.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_1.imageset/img_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_1.imageset/img_1.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_10.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_10.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_10.imageset/img_10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_10.imageset/img_10.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_2.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_2.imageset/img_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_2.imageset/img_2.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_3.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_3.imageset/img_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_3.imageset/img_3.png -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_4.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_4.imageset/img_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_4.imageset/img_4.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_5.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_5.imageset/img_5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_5.imageset/img_5.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_6.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_6.imageset/img_6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_6.imageset/img_6.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_7.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_7.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_7.imageset/img_7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_7.imageset/img_7.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_8.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_8.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_8.imageset/img_8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_8.imageset/img_8.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_9.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "img_9.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_9.imageset/img_9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/img_9.imageset/img_9.jpg -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/logo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "octo_v23.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/logo.imageset/octo_v23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/octodevnet/CustomCollectionViewLayout/325ed5471e297aeefb020502d2924f953fd27e43/Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Assets.xcassets/logo.imageset/octo_v23.png -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/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 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTAppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 3/31/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class OCTAppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTBaseCollectionViewLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OCTBaseCollectionViewLayout.swift 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class OCTBaseCollectionViewLayout: UICollectionViewLayout { 12 | private var _layoutMap = [IndexPath : UICollectionViewLayoutAttributes]() 13 | private var _columnsYoffset: [CGFloat]! 14 | private var _contentSize: CGSize! 15 | 16 | private(set) var totalItemsInSection = 0 17 | 18 | var totalColumns = 0 19 | var interItemsSpacing: CGFloat = 8 20 | 21 | //MARK: getters 22 | var contentInsets: UIEdgeInsets { 23 | return collectionView!.contentInset 24 | } 25 | 26 | override var collectionViewContentSize: CGSize { 27 | return _contentSize 28 | } 29 | 30 | //MARK: Override methods 31 | override func prepare() { 32 | _layoutMap.removeAll() 33 | _columnsYoffset = Array(repeating: 0, count: totalColumns) 34 | 35 | totalItemsInSection = collectionView!.numberOfItems(inSection: 0) 36 | 37 | if totalItemsInSection > 0 && totalColumns > 0 { 38 | self.calculateItemsSize() 39 | 40 | var itemIndex = 0 41 | var contentSizeHeight: CGFloat = 0 42 | 43 | while itemIndex < totalItemsInSection { 44 | let indexPath = IndexPath(item: itemIndex, section: 0) 45 | let columnIndex = self.columnIndexForItemAt(indexPath: indexPath) 46 | 47 | let attributeRect = calculateItemFrame(indexPath: indexPath, columnIndex: columnIndex, columnYoffset: _columnsYoffset[columnIndex]) 48 | let targetLayoutAttributes = UICollectionViewLayoutAttributes.init(forCellWith: indexPath) 49 | targetLayoutAttributes.frame = attributeRect 50 | 51 | contentSizeHeight = max(attributeRect.maxY, contentSizeHeight) 52 | _columnsYoffset[columnIndex] = attributeRect.maxY + interItemsSpacing 53 | _layoutMap[indexPath] = targetLayoutAttributes 54 | 55 | itemIndex += 1 56 | } 57 | 58 | 59 | _contentSize = CGSize(width: collectionView!.bounds.width - contentInsets.left - contentInsets.right, 60 | height: contentSizeHeight) 61 | } 62 | } 63 | 64 | override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 65 | var layoutAttributesArray = [UICollectionViewLayoutAttributes]() 66 | 67 | for (_, layoutAttributes) in _layoutMap { 68 | if rect.intersects(layoutAttributes.frame) { 69 | layoutAttributesArray.append(layoutAttributes) 70 | } 71 | } 72 | 73 | return layoutAttributesArray 74 | } 75 | 76 | override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 77 | return _layoutMap[indexPath] 78 | } 79 | 80 | //MARK: Abstract methods 81 | func columnIndexForItemAt(indexPath: IndexPath) -> Int { 82 | return indexPath.item % totalColumns 83 | } 84 | func calculateItemFrame(indexPath: IndexPath, columnIndex: Int, columnYoffset: CGFloat) -> CGRect { 85 | return CGRect.zero 86 | } 87 | 88 | func calculateItemsSize() {} 89 | } 90 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTCollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OCTCollectionViewCell.swift 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by fantom on 4/4/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class OCTCollectionViewCell: UICollectionViewCell { 12 | @IBOutlet weak var imgView: UIImageView! 13 | 14 | override func awakeFromNib() { 15 | super.awakeFromNib() 16 | imgView.layer.cornerRadius = 8 17 | imgView.clipsToBounds = true 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTCollectionViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTGalleryLayout_v1.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OCTCollectionViewLayout_v1.swift 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 3/31/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private let kReducedHeightColumnIndex = 1 12 | private let kItemHeightAspect: CGFloat = 2 13 | 14 | class OCTGalleryLayout_v1: OCTBaseCollectionViewLayout { 15 | private var _itemSize: CGSize! 16 | private var _columnsXoffset: [CGFloat]! 17 | 18 | //MARK: Init 19 | required init?(coder aDecoder: NSCoder) { 20 | super.init(coder: aDecoder) 21 | self.totalColumns = 3 22 | } 23 | 24 | //MARK: Override getters 25 | override var description: String { 26 | return "Layout v1" 27 | } 28 | 29 | //MARK: Override Abstract methods 30 | override func columnIndexForItemAt(indexPath: IndexPath) -> Int { 31 | //If last item is single in row, we move it to reduced column, to make it looks nice 32 | let columnIndex = indexPath.item % totalColumns 33 | return self.isLastItemSingleInRow(indexPath) ? kReducedHeightColumnIndex : columnIndex 34 | } 35 | 36 | override func calculateItemFrame(indexPath: IndexPath, columnIndex: Int, columnYoffset: CGFloat) -> CGRect { 37 | let rowIndex = indexPath.item / totalColumns 38 | let halfItemHeight = (_itemSize.height - interItemsSpacing) / 2 39 | 40 | //Resolving Item height 41 | var itemHeight = _itemSize.height 42 | 43 | // By our logic, first and last items in reduced height column have height divided by 2. 44 | if (rowIndex == 0 && columnIndex == kReducedHeightColumnIndex) || self.isLastItemSingleInRow(indexPath) { 45 | itemHeight = halfItemHeight 46 | } 47 | 48 | return CGRect(x: _columnsXoffset[columnIndex], y: columnYoffset, width: _itemSize.width, height: itemHeight) 49 | } 50 | 51 | override func calculateItemsSize() { 52 | let contentWidthWithoutIndents = collectionView!.bounds.width - contentInsets.left - contentInsets.right 53 | let itemWidth = (contentWidthWithoutIndents - (CGFloat(totalColumns) - 1) * interItemsSpacing) / CGFloat(totalColumns) 54 | let itemHeight = itemWidth * kItemHeightAspect 55 | 56 | _itemSize = CGSize(width: itemWidth, height: itemHeight) 57 | 58 | // Calculating offsets by X for each column 59 | _columnsXoffset = [] 60 | 61 | for columnIndex in 0...(totalColumns - 1) { 62 | _columnsXoffset.append(CGFloat(columnIndex) * (_itemSize.width + interItemsSpacing)) 63 | } 64 | } 65 | 66 | //MARK: Private methods 67 | private func isLastItemSingleInRow(_ indexPath: IndexPath) -> Bool { 68 | return indexPath.item == (totalItemsInSection - 1) && indexPath.item % totalColumns == 0 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTGalleryLayout_v2.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OCTCollectionViewLayout_v2.swift 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 4/3/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private let kSideItemWidthCoef: CGFloat = 0.3 12 | private let kSideItemHeightAspect: CGFloat = 1 13 | private let kNumberOfSideItems = 3 14 | 15 | class OCTGalleryLayout_v2: OCTBaseCollectionViewLayout { 16 | private var _mainItemSize: CGSize! 17 | private var _sideItemSize: CGSize! 18 | private var _columnsXoffset: [CGFloat]! 19 | 20 | //MARK: Init 21 | required init?(coder aDecoder: NSCoder) { 22 | super.init(coder: aDecoder) 23 | self.totalColumns = 2 24 | } 25 | 26 | //MARK: Override getters 27 | override var description: String { 28 | return "Layout v2" 29 | } 30 | 31 | //MARK: Override Abstract methods 32 | override func columnIndexForItemAt(indexPath: IndexPath) -> Int { 33 | let totalItemsInRow = kNumberOfSideItems + 1 34 | let columnIndex = indexPath.item % totalItemsInRow 35 | let columnIndexLimit = totalColumns - 1 36 | 37 | return columnIndex > columnIndexLimit ? columnIndexLimit : columnIndex 38 | } 39 | 40 | override func calculateItemFrame(indexPath: IndexPath, columnIndex: Int, columnYoffset: CGFloat) -> CGRect { 41 | let size = columnIndex == 0 ? _mainItemSize : _sideItemSize 42 | return CGRect(origin: CGPoint(x: _columnsXoffset[columnIndex], y: columnYoffset), size: size!) 43 | } 44 | 45 | override func calculateItemsSize() { 46 | let floatNumberOfSideItems = CGFloat(kNumberOfSideItems) 47 | let contentWidthWithoutIndents = collectionView!.bounds.width - contentInsets.left - contentInsets.right 48 | let resolvedContentWidth = contentWidthWithoutIndents - interItemsSpacing 49 | 50 | // We need to calculate side item size first, in order to calculate main item height 51 | let sideItemWidth = resolvedContentWidth * kSideItemWidthCoef 52 | let sideItemHeight = sideItemWidth * kSideItemHeightAspect 53 | 54 | _sideItemSize = CGSize(width: sideItemWidth, height: sideItemHeight) 55 | 56 | // Now we can calculate main item height 57 | let mainItemWidth = resolvedContentWidth - sideItemWidth 58 | let mainItemHeight = sideItemHeight * floatNumberOfSideItems + ((floatNumberOfSideItems - 1) * interItemsSpacing) 59 | 60 | _mainItemSize = CGSize(width: mainItemWidth, height: mainItemHeight) 61 | 62 | // Calculating offsets by X for each column 63 | _columnsXoffset = [0, _mainItemSize.width + interItemsSpacing] 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Swift/OCTCustomCollectionViewLayout/OCTCustomCollectionViewLayout/OCTMainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // OCTCustomCollectionViewLayout 4 | // 5 | // Created by dmitry.brovkin on 3/31/17. 6 | // Copyright © 2017 dmitry.brovkin. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private let kReuseCellID = "reuseCellID" 12 | private let kImgName = "img_" 13 | private let kTotalImgs = 10 14 | 15 | class OCTMainViewController: UIViewController, UICollectionViewDataSource { 16 | @IBOutlet private weak var collectionView: UICollectionView! 17 | 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | 21 | self.automaticallyAdjustsScrollViewInsets = false 22 | self.title = collectionView.collectionViewLayout.description 23 | 24 | self.collectionView.contentInset = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8) 25 | self.collectionView.register(UINib(nibName: "\(OCTCollectionViewCell.self)", bundle: nil), forCellWithReuseIdentifier: kReuseCellID) 26 | } 27 | 28 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 29 | return 13 30 | } 31 | 32 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 33 | let imgNumber = indexPath.item % kTotalImgs + 1 34 | let imageName = kImgName + "\(imgNumber)" 35 | 36 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kReuseCellID, for: indexPath) as! OCTCollectionViewCell 37 | cell.imgView!.image = UIImage(named: imageName) 38 | 39 | return cell 40 | } 41 | 42 | override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { 43 | super.viewWillTransition(to: size, with: coordinator) 44 | self.collectionView.collectionViewLayout.invalidateLayout() 45 | } 46 | } 47 | 48 | --------------------------------------------------------------------------------