├── .gitignore ├── Example ├── BookShelfExample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── BookShelfExample.xccheckout │ │ └── xcuserdata │ │ │ ├── michal.zaborowski.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ │ │ └── mientus.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ ├── michal.zaborowski.xcuserdatad │ │ └── xcschemes │ │ │ ├── BookShelfExample.xcscheme │ │ │ └── xcschememanagement.plist │ │ └── mientus.xcuserdatad │ │ └── xcschemes │ │ ├── BookShelfExample.xcscheme │ │ └── xcschememanagement.plist ├── BookShelfExample │ ├── BSAppDelegate.h │ ├── BSAppDelegate.m │ ├── BSViewController.h │ ├── BSViewController.m │ ├── Base.lproj │ │ └── Main.storyboard │ ├── BookShelfExample-Info.plist │ ├── BookShelfExample-Prefix.pch │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── LaunchImage.launchimage │ │ │ └── Contents.json │ │ ├── background.imageset │ │ │ ├── Contents.json │ │ │ └── background.png │ │ ├── book.imageset │ │ │ ├── Contents.json │ │ │ └── book.png │ │ └── bookshelf.imageset │ │ │ ├── Contents.json │ │ │ └── bookshelf.png │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m ├── BookShelfExampleTests │ ├── BookShelfExampleTests-Info.plist │ ├── BookShelfExampleTests.m │ └── en.lproj │ │ └── InfoPlist.strings ├── LXReorderableCollectionViewFlowLayout.h ├── LXReorderableCollectionViewFlowLayout.m └── MZBookShelfDecorationView.xib ├── LICENSE ├── README.md ├── Screens └── 1.png └── Source ├── MZBookShelfCollectionViewLayout.h └── MZBookShelfCollectionViewLayout.m /.gitignore: -------------------------------------------------------------------------------- 1 | # CocoaPods 2 | # 3 | # We recommend against adding the Pods directory to your .gitignore. However 4 | # you should judge for yourself, the pros and cons are mentioned at: 5 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? 6 | # 7 | # Pods/ 8 | 9 | -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1F33D3DF194B23F400E77DCF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F33D3DE194B23F400E77DCF /* Foundation.framework */; }; 11 | 1F33D3E1194B23F400E77DCF /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F33D3E0194B23F400E77DCF /* CoreGraphics.framework */; }; 12 | 1F33D3E3194B23F400E77DCF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F33D3E2194B23F400E77DCF /* UIKit.framework */; }; 13 | 1F33D3E9194B23F400E77DCF /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1F33D3E7194B23F400E77DCF /* InfoPlist.strings */; }; 14 | 1F33D3EB194B23F400E77DCF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F33D3EA194B23F400E77DCF /* main.m */; }; 15 | 1F33D3EF194B23F400E77DCF /* BSAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F33D3EE194B23F400E77DCF /* BSAppDelegate.m */; }; 16 | 1F33D3F2194B23F400E77DCF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1F33D3F0194B23F400E77DCF /* Main.storyboard */; }; 17 | 1F33D3F5194B23F400E77DCF /* BSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F33D3F4194B23F400E77DCF /* BSViewController.m */; }; 18 | 1F33D3F7194B23F400E77DCF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1F33D3F6194B23F400E77DCF /* Images.xcassets */; }; 19 | 1F33D3FE194B23F400E77DCF /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F33D3FD194B23F400E77DCF /* XCTest.framework */; }; 20 | 1F33D3FF194B23F400E77DCF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F33D3DE194B23F400E77DCF /* Foundation.framework */; }; 21 | 1F33D400194B23F400E77DCF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F33D3E2194B23F400E77DCF /* UIKit.framework */; }; 22 | 1F33D408194B23F400E77DCF /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1F33D406194B23F400E77DCF /* InfoPlist.strings */; }; 23 | 1F33D40A194B23F400E77DCF /* BookShelfExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F33D409194B23F400E77DCF /* BookShelfExampleTests.m */; }; 24 | 1F33D415194B265A00E77DCF /* MZBookShelfCollectionViewLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F33D414194B265A00E77DCF /* MZBookShelfCollectionViewLayout.m */; }; 25 | 1F33D418194B268200E77DCF /* MZBookShelfDecorationView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F33D417194B268200E77DCF /* MZBookShelfDecorationView.xib */; }; 26 | 1F33D41B194B2AEE00E77DCF /* LXReorderableCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F33D41A194B2AEE00E77DCF /* LXReorderableCollectionViewFlowLayout.m */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | 1F33D401194B23F400E77DCF /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 1F33D3D3194B23F400E77DCF /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 1F33D3DA194B23F400E77DCF; 35 | remoteInfo = BookShelfExample; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXFileReference section */ 40 | 1F33D3DB194B23F400E77DCF /* BookShelfExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BookShelfExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 1F33D3DE194B23F400E77DCF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 42 | 1F33D3E0194B23F400E77DCF /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 43 | 1F33D3E2194B23F400E77DCF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 44 | 1F33D3E6194B23F400E77DCF /* BookShelfExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BookShelfExample-Info.plist"; sourceTree = ""; }; 45 | 1F33D3E8194B23F400E77DCF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 46 | 1F33D3EA194B23F400E77DCF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 47 | 1F33D3EC194B23F400E77DCF /* BookShelfExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BookShelfExample-Prefix.pch"; sourceTree = ""; }; 48 | 1F33D3ED194B23F400E77DCF /* BSAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSAppDelegate.h; sourceTree = ""; }; 49 | 1F33D3EE194B23F400E77DCF /* BSAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSAppDelegate.m; sourceTree = ""; }; 50 | 1F33D3F1194B23F400E77DCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 51 | 1F33D3F3194B23F400E77DCF /* BSViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSViewController.h; sourceTree = ""; }; 52 | 1F33D3F4194B23F400E77DCF /* BSViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSViewController.m; sourceTree = ""; }; 53 | 1F33D3F6194B23F400E77DCF /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 54 | 1F33D3FC194B23F400E77DCF /* BookShelfExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BookShelfExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 1F33D3FD194B23F400E77DCF /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 56 | 1F33D405194B23F400E77DCF /* BookShelfExampleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "BookShelfExampleTests-Info.plist"; sourceTree = ""; }; 57 | 1F33D407194B23F400E77DCF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 58 | 1F33D409194B23F400E77DCF /* BookShelfExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BookShelfExampleTests.m; sourceTree = ""; }; 59 | 1F33D413194B265A00E77DCF /* MZBookShelfCollectionViewLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MZBookShelfCollectionViewLayout.h; path = ../Source/MZBookShelfCollectionViewLayout.h; sourceTree = ""; }; 60 | 1F33D414194B265A00E77DCF /* MZBookShelfCollectionViewLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MZBookShelfCollectionViewLayout.m; path = ../Source/MZBookShelfCollectionViewLayout.m; sourceTree = ""; }; 61 | 1F33D417194B268200E77DCF /* MZBookShelfDecorationView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MZBookShelfDecorationView.xib; path = ../MZBookShelfDecorationView.xib; sourceTree = ""; }; 62 | 1F33D419194B2AEE00E77DCF /* LXReorderableCollectionViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LXReorderableCollectionViewFlowLayout.h; sourceTree = ""; }; 63 | 1F33D41A194B2AEE00E77DCF /* LXReorderableCollectionViewFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LXReorderableCollectionViewFlowLayout.m; sourceTree = ""; }; 64 | /* End PBXFileReference section */ 65 | 66 | /* Begin PBXFrameworksBuildPhase section */ 67 | 1F33D3D8194B23F400E77DCF /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | 1F33D3E1194B23F400E77DCF /* CoreGraphics.framework in Frameworks */, 72 | 1F33D3E3194B23F400E77DCF /* UIKit.framework in Frameworks */, 73 | 1F33D3DF194B23F400E77DCF /* Foundation.framework in Frameworks */, 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | 1F33D3F9194B23F400E77DCF /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | 1F33D3FE194B23F400E77DCF /* XCTest.framework in Frameworks */, 82 | 1F33D400194B23F400E77DCF /* UIKit.framework in Frameworks */, 83 | 1F33D3FF194B23F400E77DCF /* Foundation.framework in Frameworks */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXFrameworksBuildPhase section */ 88 | 89 | /* Begin PBXGroup section */ 90 | 1F33D3D2194B23F400E77DCF = { 91 | isa = PBXGroup; 92 | children = ( 93 | 1F33D416194B266000E77DCF /* Source */, 94 | 1F33D3E4194B23F400E77DCF /* BookShelfExample */, 95 | 1F33D403194B23F400E77DCF /* BookShelfExampleTests */, 96 | 1F33D3DD194B23F400E77DCF /* Frameworks */, 97 | 1F33D3DC194B23F400E77DCF /* Products */, 98 | 1F33D419194B2AEE00E77DCF /* LXReorderableCollectionViewFlowLayout.h */, 99 | 1F33D41A194B2AEE00E77DCF /* LXReorderableCollectionViewFlowLayout.m */, 100 | ); 101 | sourceTree = ""; 102 | }; 103 | 1F33D3DC194B23F400E77DCF /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 1F33D3DB194B23F400E77DCF /* BookShelfExample.app */, 107 | 1F33D3FC194B23F400E77DCF /* BookShelfExampleTests.xctest */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | 1F33D3DD194B23F400E77DCF /* Frameworks */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 1F33D3DE194B23F400E77DCF /* Foundation.framework */, 116 | 1F33D3E0194B23F400E77DCF /* CoreGraphics.framework */, 117 | 1F33D3E2194B23F400E77DCF /* UIKit.framework */, 118 | 1F33D3FD194B23F400E77DCF /* XCTest.framework */, 119 | ); 120 | name = Frameworks; 121 | sourceTree = ""; 122 | }; 123 | 1F33D3E4194B23F400E77DCF /* BookShelfExample */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 1F33D417194B268200E77DCF /* MZBookShelfDecorationView.xib */, 127 | 1F33D3ED194B23F400E77DCF /* BSAppDelegate.h */, 128 | 1F33D3EE194B23F400E77DCF /* BSAppDelegate.m */, 129 | 1F33D3F0194B23F400E77DCF /* Main.storyboard */, 130 | 1F33D3F3194B23F400E77DCF /* BSViewController.h */, 131 | 1F33D3F4194B23F400E77DCF /* BSViewController.m */, 132 | 1F33D3F6194B23F400E77DCF /* Images.xcassets */, 133 | 1F33D3E5194B23F400E77DCF /* Supporting Files */, 134 | ); 135 | path = BookShelfExample; 136 | sourceTree = ""; 137 | }; 138 | 1F33D3E5194B23F400E77DCF /* Supporting Files */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | 1F33D3E6194B23F400E77DCF /* BookShelfExample-Info.plist */, 142 | 1F33D3E7194B23F400E77DCF /* InfoPlist.strings */, 143 | 1F33D3EA194B23F400E77DCF /* main.m */, 144 | 1F33D3EC194B23F400E77DCF /* BookShelfExample-Prefix.pch */, 145 | ); 146 | name = "Supporting Files"; 147 | sourceTree = ""; 148 | }; 149 | 1F33D403194B23F400E77DCF /* BookShelfExampleTests */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | 1F33D409194B23F400E77DCF /* BookShelfExampleTests.m */, 153 | 1F33D404194B23F400E77DCF /* Supporting Files */, 154 | ); 155 | path = BookShelfExampleTests; 156 | sourceTree = ""; 157 | }; 158 | 1F33D404194B23F400E77DCF /* Supporting Files */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 1F33D405194B23F400E77DCF /* BookShelfExampleTests-Info.plist */, 162 | 1F33D406194B23F400E77DCF /* InfoPlist.strings */, 163 | ); 164 | name = "Supporting Files"; 165 | sourceTree = ""; 166 | }; 167 | 1F33D416194B266000E77DCF /* Source */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 1F33D413194B265A00E77DCF /* MZBookShelfCollectionViewLayout.h */, 171 | 1F33D414194B265A00E77DCF /* MZBookShelfCollectionViewLayout.m */, 172 | ); 173 | name = Source; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXGroup section */ 177 | 178 | /* Begin PBXNativeTarget section */ 179 | 1F33D3DA194B23F400E77DCF /* BookShelfExample */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = 1F33D40D194B23F400E77DCF /* Build configuration list for PBXNativeTarget "BookShelfExample" */; 182 | buildPhases = ( 183 | 1F33D3D7194B23F400E77DCF /* Sources */, 184 | 1F33D3D8194B23F400E77DCF /* Frameworks */, 185 | 1F33D3D9194B23F400E77DCF /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | ); 191 | name = BookShelfExample; 192 | productName = BookShelfExample; 193 | productReference = 1F33D3DB194B23F400E77DCF /* BookShelfExample.app */; 194 | productType = "com.apple.product-type.application"; 195 | }; 196 | 1F33D3FB194B23F400E77DCF /* BookShelfExampleTests */ = { 197 | isa = PBXNativeTarget; 198 | buildConfigurationList = 1F33D410194B23F400E77DCF /* Build configuration list for PBXNativeTarget "BookShelfExampleTests" */; 199 | buildPhases = ( 200 | 1F33D3F8194B23F400E77DCF /* Sources */, 201 | 1F33D3F9194B23F400E77DCF /* Frameworks */, 202 | 1F33D3FA194B23F400E77DCF /* Resources */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | 1F33D402194B23F400E77DCF /* PBXTargetDependency */, 208 | ); 209 | name = BookShelfExampleTests; 210 | productName = BookShelfExampleTests; 211 | productReference = 1F33D3FC194B23F400E77DCF /* BookShelfExampleTests.xctest */; 212 | productType = "com.apple.product-type.bundle.unit-test"; 213 | }; 214 | /* End PBXNativeTarget section */ 215 | 216 | /* Begin PBXProject section */ 217 | 1F33D3D3194B23F400E77DCF /* Project object */ = { 218 | isa = PBXProject; 219 | attributes = { 220 | CLASSPREFIX = BS; 221 | LastUpgradeCheck = 0510; 222 | ORGANIZATIONNAME = "Michał Zaborowski"; 223 | TargetAttributes = { 224 | 1F33D3FB194B23F400E77DCF = { 225 | TestTargetID = 1F33D3DA194B23F400E77DCF; 226 | }; 227 | }; 228 | }; 229 | buildConfigurationList = 1F33D3D6194B23F400E77DCF /* Build configuration list for PBXProject "BookShelfExample" */; 230 | compatibilityVersion = "Xcode 3.2"; 231 | developmentRegion = English; 232 | hasScannedForEncodings = 0; 233 | knownRegions = ( 234 | en, 235 | Base, 236 | ); 237 | mainGroup = 1F33D3D2194B23F400E77DCF; 238 | productRefGroup = 1F33D3DC194B23F400E77DCF /* Products */; 239 | projectDirPath = ""; 240 | projectRoot = ""; 241 | targets = ( 242 | 1F33D3DA194B23F400E77DCF /* BookShelfExample */, 243 | 1F33D3FB194B23F400E77DCF /* BookShelfExampleTests */, 244 | ); 245 | }; 246 | /* End PBXProject section */ 247 | 248 | /* Begin PBXResourcesBuildPhase section */ 249 | 1F33D3D9194B23F400E77DCF /* Resources */ = { 250 | isa = PBXResourcesBuildPhase; 251 | buildActionMask = 2147483647; 252 | files = ( 253 | 1F33D3F7194B23F400E77DCF /* Images.xcassets in Resources */, 254 | 1F33D3E9194B23F400E77DCF /* InfoPlist.strings in Resources */, 255 | 1F33D3F2194B23F400E77DCF /* Main.storyboard in Resources */, 256 | 1F33D418194B268200E77DCF /* MZBookShelfDecorationView.xib in Resources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | 1F33D3FA194B23F400E77DCF /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | 1F33D408194B23F400E77DCF /* InfoPlist.strings in Resources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | /* End PBXResourcesBuildPhase section */ 269 | 270 | /* Begin PBXSourcesBuildPhase section */ 271 | 1F33D3D7194B23F400E77DCF /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | 1F33D41B194B2AEE00E77DCF /* LXReorderableCollectionViewFlowLayout.m in Sources */, 276 | 1F33D3F5194B23F400E77DCF /* BSViewController.m in Sources */, 277 | 1F33D3EB194B23F400E77DCF /* main.m in Sources */, 278 | 1F33D3EF194B23F400E77DCF /* BSAppDelegate.m in Sources */, 279 | 1F33D415194B265A00E77DCF /* MZBookShelfCollectionViewLayout.m in Sources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | 1F33D3F8194B23F400E77DCF /* Sources */ = { 284 | isa = PBXSourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | 1F33D40A194B23F400E77DCF /* BookShelfExampleTests.m in Sources */, 288 | ); 289 | runOnlyForDeploymentPostprocessing = 0; 290 | }; 291 | /* End PBXSourcesBuildPhase section */ 292 | 293 | /* Begin PBXTargetDependency section */ 294 | 1F33D402194B23F400E77DCF /* PBXTargetDependency */ = { 295 | isa = PBXTargetDependency; 296 | target = 1F33D3DA194B23F400E77DCF /* BookShelfExample */; 297 | targetProxy = 1F33D401194B23F400E77DCF /* PBXContainerItemProxy */; 298 | }; 299 | /* End PBXTargetDependency section */ 300 | 301 | /* Begin PBXVariantGroup section */ 302 | 1F33D3E7194B23F400E77DCF /* InfoPlist.strings */ = { 303 | isa = PBXVariantGroup; 304 | children = ( 305 | 1F33D3E8194B23F400E77DCF /* en */, 306 | ); 307 | name = InfoPlist.strings; 308 | sourceTree = ""; 309 | }; 310 | 1F33D3F0194B23F400E77DCF /* Main.storyboard */ = { 311 | isa = PBXVariantGroup; 312 | children = ( 313 | 1F33D3F1194B23F400E77DCF /* Base */, 314 | ); 315 | name = Main.storyboard; 316 | sourceTree = ""; 317 | }; 318 | 1F33D406194B23F400E77DCF /* InfoPlist.strings */ = { 319 | isa = PBXVariantGroup; 320 | children = ( 321 | 1F33D407194B23F400E77DCF /* en */, 322 | ); 323 | name = InfoPlist.strings; 324 | sourceTree = ""; 325 | }; 326 | /* End PBXVariantGroup section */ 327 | 328 | /* Begin XCBuildConfiguration section */ 329 | 1F33D40B194B23F400E77DCF /* Debug */ = { 330 | isa = XCBuildConfiguration; 331 | buildSettings = { 332 | ALWAYS_SEARCH_USER_PATHS = NO; 333 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 334 | CLANG_CXX_LIBRARY = "libc++"; 335 | CLANG_ENABLE_MODULES = YES; 336 | CLANG_ENABLE_OBJC_ARC = YES; 337 | CLANG_WARN_BOOL_CONVERSION = YES; 338 | CLANG_WARN_CONSTANT_CONVERSION = YES; 339 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 340 | CLANG_WARN_EMPTY_BODY = YES; 341 | CLANG_WARN_ENUM_CONVERSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 344 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 345 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 346 | COPY_PHASE_STRIP = NO; 347 | GCC_C_LANGUAGE_STANDARD = gnu99; 348 | GCC_DYNAMIC_NO_PIC = NO; 349 | GCC_OPTIMIZATION_LEVEL = 0; 350 | GCC_PREPROCESSOR_DEFINITIONS = ( 351 | "DEBUG=1", 352 | "$(inherited)", 353 | ); 354 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 355 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 356 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 357 | GCC_WARN_UNDECLARED_SELECTOR = YES; 358 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 359 | GCC_WARN_UNUSED_FUNCTION = YES; 360 | GCC_WARN_UNUSED_VARIABLE = YES; 361 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 362 | ONLY_ACTIVE_ARCH = YES; 363 | SDKROOT = iphoneos; 364 | TARGETED_DEVICE_FAMILY = 2; 365 | }; 366 | name = Debug; 367 | }; 368 | 1F33D40C194B23F400E77DCF /* Release */ = { 369 | isa = XCBuildConfiguration; 370 | buildSettings = { 371 | ALWAYS_SEARCH_USER_PATHS = NO; 372 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 373 | CLANG_CXX_LIBRARY = "libc++"; 374 | CLANG_ENABLE_MODULES = YES; 375 | CLANG_ENABLE_OBJC_ARC = YES; 376 | CLANG_WARN_BOOL_CONVERSION = YES; 377 | CLANG_WARN_CONSTANT_CONVERSION = YES; 378 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 379 | CLANG_WARN_EMPTY_BODY = YES; 380 | CLANG_WARN_ENUM_CONVERSION = YES; 381 | CLANG_WARN_INT_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 384 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 385 | COPY_PHASE_STRIP = YES; 386 | ENABLE_NS_ASSERTIONS = NO; 387 | GCC_C_LANGUAGE_STANDARD = gnu99; 388 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 389 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 390 | GCC_WARN_UNDECLARED_SELECTOR = YES; 391 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 392 | GCC_WARN_UNUSED_FUNCTION = YES; 393 | GCC_WARN_UNUSED_VARIABLE = YES; 394 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 395 | SDKROOT = iphoneos; 396 | TARGETED_DEVICE_FAMILY = 2; 397 | VALIDATE_PRODUCT = YES; 398 | }; 399 | name = Release; 400 | }; 401 | 1F33D40E194B23F400E77DCF /* Debug */ = { 402 | isa = XCBuildConfiguration; 403 | buildSettings = { 404 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 405 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 406 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 407 | GCC_PREFIX_HEADER = "BookShelfExample/BookShelfExample-Prefix.pch"; 408 | INFOPLIST_FILE = "BookShelfExample/BookShelfExample-Info.plist"; 409 | PRODUCT_NAME = "$(TARGET_NAME)"; 410 | WRAPPER_EXTENSION = app; 411 | }; 412 | name = Debug; 413 | }; 414 | 1F33D40F194B23F400E77DCF /* Release */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 418 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 419 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 420 | GCC_PREFIX_HEADER = "BookShelfExample/BookShelfExample-Prefix.pch"; 421 | INFOPLIST_FILE = "BookShelfExample/BookShelfExample-Info.plist"; 422 | PRODUCT_NAME = "$(TARGET_NAME)"; 423 | WRAPPER_EXTENSION = app; 424 | }; 425 | name = Release; 426 | }; 427 | 1F33D411194B23F400E77DCF /* Debug */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BookShelfExample.app/BookShelfExample"; 431 | FRAMEWORK_SEARCH_PATHS = ( 432 | "$(SDKROOT)/Developer/Library/Frameworks", 433 | "$(inherited)", 434 | "$(DEVELOPER_FRAMEWORKS_DIR)", 435 | ); 436 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 437 | GCC_PREFIX_HEADER = "BookShelfExample/BookShelfExample-Prefix.pch"; 438 | GCC_PREPROCESSOR_DEFINITIONS = ( 439 | "DEBUG=1", 440 | "$(inherited)", 441 | ); 442 | INFOPLIST_FILE = "BookShelfExampleTests/BookShelfExampleTests-Info.plist"; 443 | PRODUCT_NAME = "$(TARGET_NAME)"; 444 | TEST_HOST = "$(BUNDLE_LOADER)"; 445 | WRAPPER_EXTENSION = xctest; 446 | }; 447 | name = Debug; 448 | }; 449 | 1F33D412194B23F400E77DCF /* Release */ = { 450 | isa = XCBuildConfiguration; 451 | buildSettings = { 452 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/BookShelfExample.app/BookShelfExample"; 453 | FRAMEWORK_SEARCH_PATHS = ( 454 | "$(SDKROOT)/Developer/Library/Frameworks", 455 | "$(inherited)", 456 | "$(DEVELOPER_FRAMEWORKS_DIR)", 457 | ); 458 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 459 | GCC_PREFIX_HEADER = "BookShelfExample/BookShelfExample-Prefix.pch"; 460 | INFOPLIST_FILE = "BookShelfExampleTests/BookShelfExampleTests-Info.plist"; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | TEST_HOST = "$(BUNDLE_LOADER)"; 463 | WRAPPER_EXTENSION = xctest; 464 | }; 465 | name = Release; 466 | }; 467 | /* End XCBuildConfiguration section */ 468 | 469 | /* Begin XCConfigurationList section */ 470 | 1F33D3D6194B23F400E77DCF /* Build configuration list for PBXProject "BookShelfExample" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | 1F33D40B194B23F400E77DCF /* Debug */, 474 | 1F33D40C194B23F400E77DCF /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | 1F33D40D194B23F400E77DCF /* Build configuration list for PBXNativeTarget "BookShelfExample" */ = { 480 | isa = XCConfigurationList; 481 | buildConfigurations = ( 482 | 1F33D40E194B23F400E77DCF /* Debug */, 483 | 1F33D40F194B23F400E77DCF /* Release */, 484 | ); 485 | defaultConfigurationIsVisible = 0; 486 | defaultConfigurationName = Release; 487 | }; 488 | 1F33D410194B23F400E77DCF /* Build configuration list for PBXNativeTarget "BookShelfExampleTests" */ = { 489 | isa = XCConfigurationList; 490 | buildConfigurations = ( 491 | 1F33D411194B23F400E77DCF /* Debug */, 492 | 1F33D412194B23F400E77DCF /* Release */, 493 | ); 494 | defaultConfigurationIsVisible = 0; 495 | defaultConfigurationName = Release; 496 | }; 497 | /* End XCConfigurationList section */ 498 | }; 499 | rootObject = 1F33D3D3194B23F400E77DCF /* Project object */; 500 | } 501 | -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/project.xcworkspace/xcshareddata/BookShelfExample.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 0207529F-E0F2-48F8-9BD6-55A7DB8A2FA2 9 | IDESourceControlProjectName 10 | BookShelfExample 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 57E1DEF2-D457-4088-8CF0-86D7AA0D1D0D 14 | https://github.com/m1entus/MZBookshelfCollectionViewLayout.git 15 | 16 | IDESourceControlProjectPath 17 | Example/BookShelfExample.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 57E1DEF2-D457-4088-8CF0-86D7AA0D1D0D 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/m1entus/MZBookshelfCollectionViewLayout.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 57E1DEF2-D457-4088-8CF0-86D7AA0D1D0D 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 57E1DEF2-D457-4088-8CF0-86D7AA0D1D0D 36 | IDESourceControlWCCName 37 | MZBookshelfCollectionViewLayout 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/project.xcworkspace/xcuserdata/michal.zaborowski.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1entus/MZBookshelfCollectionViewLayout/b18ed480022e3d194487f87b0669193016bb0020/Example/BookShelfExample.xcodeproj/project.xcworkspace/xcuserdata/michal.zaborowski.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/project.xcworkspace/xcuserdata/mientus.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1entus/MZBookshelfCollectionViewLayout/b18ed480022e3d194487f87b0669193016bb0020/Example/BookShelfExample.xcodeproj/project.xcworkspace/xcuserdata/mientus.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/xcuserdata/michal.zaborowski.xcuserdatad/xcschemes/BookShelfExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/xcuserdata/michal.zaborowski.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BookShelfExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1F33D3DA194B23F400E77DCF 16 | 17 | primary 18 | 19 | 20 | 1F33D3FB194B23F400E77DCF 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/xcuserdata/mientus.xcuserdatad/xcschemes/BookShelfExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /Example/BookShelfExample.xcodeproj/xcuserdata/mientus.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | BookShelfExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 1F33D3DA194B23F400E77DCF 16 | 17 | primary 18 | 19 | 20 | 1F33D3FB194B23F400E77DCF 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/BookShelfExample/BSAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // BSAppDelegate.h 3 | // BookShelfExample 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BSAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Example/BookShelfExample/BSAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // BSAppDelegate.m 3 | // BookShelfExample 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | 9 | #import "BSAppDelegate.h" 10 | 11 | @implementation BSAppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 22 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Example/BookShelfExample/BSViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BSViewController.h 3 | // BookShelfExample 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BSViewController : UICollectionViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Example/BookShelfExample/BSViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BSViewController.m 3 | // BookShelfExample 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | 9 | #import "BSViewController.h" 10 | #import "MZBookShelfCollectionViewLayout.h" 11 | 12 | @interface BSViewController () 13 | 14 | @end 15 | 16 | @implementation BSViewController 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | 22 | self.collectionView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background"]]; 23 | 24 | MZBookshelfCollectionViewLayout *layout = (id)self.collectionView.collectionViewLayout; 25 | [layout registerNib:[UINib nibWithNibName:@"MZBookShelfDecorationView" bundle:nil] forDecorationViewOfKind:MZBookshelfCollectionViewLayoutDecorationViewKind]; 26 | } 27 | 28 | - (CGFloat)widthForSection:(NSInteger)section 29 | { 30 | UICollectionViewFlowLayout *layout = (id)self.collectionView.collectionViewLayout; 31 | 32 | CGFloat availableWidth = layout.collectionViewContentSize.width - (layout.sectionInset.left + layout.sectionInset.right); 33 | int itemsAcross = floorf((availableWidth + layout.minimumInteritemSpacing) / (layout.itemSize.width + layout.minimumInteritemSpacing)); 34 | int itemCount = [layout.collectionView numberOfItemsInSection:section]; 35 | int rows = ceilf(itemCount/(float)itemsAcross); 36 | CGFloat itemsInRow = ceilf((double)itemCount /rows); 37 | 38 | return itemsInRow * (layout.itemSize.width + layout.minimumInteritemSpacing) + (layout.sectionInset.left + layout.sectionInset.right); 39 | } 40 | 41 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout referenceSizeForDecorationViewForRow:(NSInteger)row inSection:(NSInteger)section 42 | { 43 | if (section == 0) { 44 | if (collectionViewLayout.scrollDirection == UICollectionViewScrollDirectionHorizontal) { 45 | return CGSizeMake([self widthForSection:section], 113); 46 | } else { 47 | return CGSizeMake(collectionViewLayout.collectionViewContentSize.width, 113); 48 | } 49 | 50 | } 51 | return CGSizeZero; 52 | } 53 | 54 | - (UIOffset)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout decorationViewAdjustmentForRow:(NSInteger)row inSection:(NSInteger)section 55 | { 56 | return UIOffsetMake(8, -30); 57 | } 58 | 59 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 60 | { 61 | return 2; 62 | } 63 | 64 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 65 | { 66 | return 16; 67 | } 68 | 69 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 70 | { 71 | UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell" forIndexPath:indexPath]; 72 | 73 | return cell; 74 | } 75 | 76 | - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath 77 | { 78 | UICollectionReusableView *reusableView = [collectionView dequeueReusableSupplementaryViewOfKind:kind withReuseIdentifier:@"Header" forIndexPath:indexPath]; 79 | return reusableView; 80 | } 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /Example/BookShelfExample/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 | -------------------------------------------------------------------------------- /Example/BookShelfExample/BookShelfExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.example.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations~ipad 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/BookShelfExample/BookShelfExample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "ipad", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "ipad", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "ipad", 15 | "size" : "40x40", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "40x40", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "76x76", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "76x76", 31 | "scale" : "2x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "1x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "extent" : "full-screen", 14 | "minimum-system-version" : "7.0", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "portrait", 19 | "idiom" : "ipad", 20 | "extent" : "full-screen", 21 | "minimum-system-version" : "7.0", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "landscape", 26 | "idiom" : "ipad", 27 | "extent" : "full-screen", 28 | "minimum-system-version" : "7.0", 29 | "scale" : "2x" 30 | } 31 | ], 32 | "info" : { 33 | "version" : 1, 34 | "author" : "xcode" 35 | } 36 | } -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/background.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "background.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/background.imageset/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1entus/MZBookshelfCollectionViewLayout/b18ed480022e3d194487f87b0669193016bb0020/Example/BookShelfExample/Images.xcassets/background.imageset/background.png -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/book.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "book.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/book.imageset/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1entus/MZBookshelfCollectionViewLayout/b18ed480022e3d194487f87b0669193016bb0020/Example/BookShelfExample/Images.xcassets/book.imageset/book.png -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/bookshelf.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "bookshelf.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /Example/BookShelfExample/Images.xcassets/bookshelf.imageset/bookshelf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1entus/MZBookshelfCollectionViewLayout/b18ed480022e3d194487f87b0669193016bb0020/Example/BookShelfExample/Images.xcassets/bookshelf.imageset/bookshelf.png -------------------------------------------------------------------------------- /Example/BookShelfExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/BookShelfExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // BookShelfExample 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "BSAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([BSAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/BookShelfExampleTests/BookShelfExampleTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.example.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example/BookShelfExampleTests/BookShelfExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // BookShelfExampleTests.m 3 | // BookShelfExampleTests 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BookShelfExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation BookShelfExampleTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /Example/BookShelfExampleTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example/LXReorderableCollectionViewFlowLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // LXReorderableCollectionViewFlowLayout.h 3 | // 4 | // Created by Stan Chang Khin Boon on 1/10/12. 5 | // Copyright (c) 2012 d--buzz. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | @interface LXReorderableCollectionViewFlowLayout : UICollectionViewFlowLayout 11 | 12 | @property (assign, nonatomic) CGFloat scrollingSpeed; 13 | @property (assign, nonatomic) UIEdgeInsets scrollingTriggerEdgeInsets; 14 | @property (strong, nonatomic, readonly) UILongPressGestureRecognizer *longPressGestureRecognizer; 15 | @property (strong, nonatomic, readonly) UIPanGestureRecognizer *panGestureRecognizer; 16 | 17 | - (void)setUpGestureRecognizersOnCollectionView __attribute__((deprecated("Calls to setUpGestureRecognizersOnCollectionView method are not longer needed as setup are done automatically through KVO."))); 18 | 19 | @end 20 | 21 | @protocol LXReorderableCollectionViewDataSource 22 | 23 | @optional 24 | 25 | - (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath willMoveToIndexPath:(NSIndexPath *)toIndexPath; 26 | - (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath didMoveToIndexPath:(NSIndexPath *)toIndexPath; 27 | 28 | - (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath; 29 | - (BOOL)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)fromIndexPath canMoveToIndexPath:(NSIndexPath *)toIndexPath; 30 | 31 | @end 32 | 33 | @protocol LXReorderableCollectionViewDelegateFlowLayout 34 | @optional 35 | 36 | - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath; 37 | - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath; 38 | - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath; 39 | - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath; 40 | 41 | @end -------------------------------------------------------------------------------- /Example/LXReorderableCollectionViewFlowLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // LXReorderableCollectionViewFlowLayout.m 3 | // 4 | // Created by Stan Chang Khin Boon on 1/10/12. 5 | // Copyright (c) 2012 d--buzz. All rights reserved. 6 | // 7 | 8 | #import "LXReorderableCollectionViewFlowLayout.h" 9 | #import 10 | #import 11 | 12 | #define LX_FRAMES_PER_SECOND 60.0 13 | 14 | #ifndef CGGEOMETRY_LXSUPPORT_H_ 15 | CG_INLINE CGPoint 16 | LXS_CGPointAdd(CGPoint point1, CGPoint point2) { 17 | return CGPointMake(point1.x + point2.x, point1.y + point2.y); 18 | } 19 | #endif 20 | 21 | typedef NS_ENUM(NSInteger, LXScrollingDirection) { 22 | LXScrollingDirectionUnknown = 0, 23 | LXScrollingDirectionUp, 24 | LXScrollingDirectionDown, 25 | LXScrollingDirectionLeft, 26 | LXScrollingDirectionRight 27 | }; 28 | 29 | static NSString * const kLXScrollingDirectionKey = @"LXScrollingDirection"; 30 | static NSString * const kLXCollectionViewKeyPath = @"collectionView"; 31 | 32 | @interface CADisplayLink (LX_userInfo) 33 | @property (nonatomic, copy) NSDictionary *LX_userInfo; 34 | @end 35 | 36 | @implementation CADisplayLink (LX_userInfo) 37 | - (void) setLX_userInfo:(NSDictionary *) LX_userInfo { 38 | objc_setAssociatedObject(self, "LX_userInfo", LX_userInfo, OBJC_ASSOCIATION_COPY); 39 | } 40 | 41 | - (NSDictionary *) LX_userInfo { 42 | return objc_getAssociatedObject(self, "LX_userInfo"); 43 | } 44 | @end 45 | 46 | @interface UICollectionViewCell (LXReorderableCollectionViewFlowLayout) 47 | 48 | - (UIImage *)LX_rasterizedImage; 49 | 50 | @end 51 | 52 | @implementation UICollectionViewCell (LXReorderableCollectionViewFlowLayout) 53 | 54 | - (UIImage *)LX_rasterizedImage { 55 | UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.isOpaque, 0.0f); 56 | [self.layer renderInContext:UIGraphicsGetCurrentContext()]; 57 | UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 58 | UIGraphicsEndImageContext(); 59 | return image; 60 | } 61 | 62 | @end 63 | 64 | @interface LXReorderableCollectionViewFlowLayout () 65 | 66 | @property (strong, nonatomic) NSIndexPath *selectedItemIndexPath; 67 | @property (strong, nonatomic) UIView *currentView; 68 | @property (assign, nonatomic) CGPoint currentViewCenter; 69 | @property (assign, nonatomic) CGPoint panTranslationInCollectionView; 70 | @property (strong, nonatomic) CADisplayLink *displayLink; 71 | 72 | @property (assign, nonatomic, readonly) id dataSource; 73 | @property (assign, nonatomic, readonly) id delegate; 74 | 75 | @end 76 | 77 | @implementation LXReorderableCollectionViewFlowLayout 78 | 79 | - (void)setDefaults { 80 | _scrollingSpeed = 300.0f; 81 | _scrollingTriggerEdgeInsets = UIEdgeInsetsMake(50.0f, 50.0f, 50.0f, 50.0f); 82 | } 83 | 84 | - (void)setupCollectionView { 85 | _longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self 86 | action:@selector(handleLongPressGesture:)]; 87 | _longPressGestureRecognizer.delegate = self; 88 | 89 | // Links the default long press gesture recognizer to the custom long press gesture recognizer we are creating now 90 | // by enforcing failure dependency so that they doesn't clash. 91 | for (UIGestureRecognizer *gestureRecognizer in self.collectionView.gestureRecognizers) { 92 | if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) { 93 | [gestureRecognizer requireGestureRecognizerToFail:_longPressGestureRecognizer]; 94 | } 95 | } 96 | 97 | [self.collectionView addGestureRecognizer:_longPressGestureRecognizer]; 98 | 99 | _panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self 100 | action:@selector(handlePanGesture:)]; 101 | _panGestureRecognizer.delegate = self; 102 | [self.collectionView addGestureRecognizer:_panGestureRecognizer]; 103 | 104 | // Useful in multiple scenarios: one common scenario being when the Notification Center drawer is pulled down 105 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleApplicationWillResignActive:) name: UIApplicationWillResignActiveNotification object:nil]; 106 | } 107 | 108 | - (id)init { 109 | self = [super init]; 110 | if (self) { 111 | [self setDefaults]; 112 | [self addObserver:self forKeyPath:kLXCollectionViewKeyPath options:NSKeyValueObservingOptionNew context:nil]; 113 | } 114 | return self; 115 | } 116 | 117 | - (id)initWithCoder:(NSCoder *)aDecoder { 118 | self = [super initWithCoder:aDecoder]; 119 | if (self) { 120 | [self setDefaults]; 121 | [self addObserver:self forKeyPath:kLXCollectionViewKeyPath options:NSKeyValueObservingOptionNew context:nil]; 122 | } 123 | return self; 124 | } 125 | 126 | - (void)dealloc { 127 | [self invalidatesScrollTimer]; 128 | [self removeObserver:self forKeyPath:kLXCollectionViewKeyPath]; 129 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil]; 130 | } 131 | 132 | - (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes { 133 | if ([layoutAttributes.indexPath isEqual:self.selectedItemIndexPath]) { 134 | layoutAttributes.hidden = YES; 135 | } 136 | } 137 | 138 | - (id)dataSource { 139 | return (id)self.collectionView.dataSource; 140 | } 141 | 142 | - (id)delegate { 143 | return (id)self.collectionView.delegate; 144 | } 145 | 146 | - (void)invalidateLayoutIfNecessary { 147 | NSIndexPath *newIndexPath = [self.collectionView indexPathForItemAtPoint:self.currentView.center]; 148 | NSIndexPath *previousIndexPath = self.selectedItemIndexPath; 149 | 150 | if ((newIndexPath == nil) || [newIndexPath isEqual:previousIndexPath]) { 151 | return; 152 | } 153 | 154 | if ([self.dataSource respondsToSelector:@selector(collectionView:itemAtIndexPath:canMoveToIndexPath:)] && 155 | ![self.dataSource collectionView:self.collectionView itemAtIndexPath:previousIndexPath canMoveToIndexPath:newIndexPath]) { 156 | return; 157 | } 158 | 159 | self.selectedItemIndexPath = newIndexPath; 160 | 161 | if ([self.dataSource respondsToSelector:@selector(collectionView:itemAtIndexPath:willMoveToIndexPath:)]) { 162 | [self.dataSource collectionView:self.collectionView itemAtIndexPath:previousIndexPath willMoveToIndexPath:newIndexPath]; 163 | } 164 | 165 | __weak typeof(self) weakSelf = self; 166 | [self.collectionView performBatchUpdates:^{ 167 | __strong typeof(self) strongSelf = weakSelf; 168 | if (strongSelf) { 169 | [strongSelf.collectionView deleteItemsAtIndexPaths:@[ previousIndexPath ]]; 170 | [strongSelf.collectionView insertItemsAtIndexPaths:@[ newIndexPath ]]; 171 | } 172 | } completion:^(BOOL finished) { 173 | __strong typeof(self) strongSelf = weakSelf; 174 | if ([strongSelf.dataSource respondsToSelector:@selector(collectionView:itemAtIndexPath:didMoveToIndexPath:)]) { 175 | [strongSelf.dataSource collectionView:strongSelf.collectionView itemAtIndexPath:previousIndexPath didMoveToIndexPath:newIndexPath]; 176 | } 177 | }]; 178 | } 179 | 180 | - (void)invalidatesScrollTimer { 181 | if (!self.displayLink.paused) { 182 | [self.displayLink invalidate]; 183 | } 184 | self.displayLink = nil; 185 | } 186 | 187 | - (void)setupScrollTimerInDirection:(LXScrollingDirection)direction { 188 | if (!self.displayLink.paused) { 189 | LXScrollingDirection oldDirection = [self.displayLink.LX_userInfo[kLXScrollingDirectionKey] integerValue]; 190 | 191 | if (direction == oldDirection) { 192 | return; 193 | } 194 | } 195 | 196 | [self invalidatesScrollTimer]; 197 | 198 | self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleScroll:)]; 199 | self.displayLink.LX_userInfo = @{ kLXScrollingDirectionKey : @(direction) }; 200 | 201 | [self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 202 | } 203 | 204 | #pragma mark - Target/Action methods 205 | 206 | // Tight loop, allocate memory sparely, even if they are stack allocation. 207 | - (void)handleScroll:(CADisplayLink *)displayLink { 208 | LXScrollingDirection direction = (LXScrollingDirection)[displayLink.LX_userInfo[kLXScrollingDirectionKey] integerValue]; 209 | if (direction == LXScrollingDirectionUnknown) { 210 | return; 211 | } 212 | 213 | CGSize frameSize = self.collectionView.bounds.size; 214 | CGSize contentSize = self.collectionView.contentSize; 215 | CGPoint contentOffset = self.collectionView.contentOffset; 216 | UIEdgeInsets contentInset = self.collectionView.contentInset; 217 | // Important to have an integer `distance` as the `contentOffset` property automatically gets rounded 218 | // and it would diverge from the view's center resulting in a "cell is slipping away under finger"-bug. 219 | CGFloat distance = rint(self.scrollingSpeed / LX_FRAMES_PER_SECOND); 220 | CGPoint translation = CGPointZero; 221 | 222 | switch(direction) { 223 | case LXScrollingDirectionUp: { 224 | distance = -distance; 225 | CGFloat minY = 0.0f - contentInset.top; 226 | 227 | if ((contentOffset.y + distance) <= minY) { 228 | distance = -contentOffset.y - contentInset.top; 229 | } 230 | 231 | translation = CGPointMake(0.0f, distance); 232 | } break; 233 | case LXScrollingDirectionDown: { 234 | CGFloat maxY = MAX(contentSize.height, frameSize.height) - frameSize.height + contentInset.bottom; 235 | 236 | if ((contentOffset.y + distance) >= maxY) { 237 | distance = maxY - contentOffset.y; 238 | } 239 | 240 | translation = CGPointMake(0.0f, distance); 241 | } break; 242 | case LXScrollingDirectionLeft: { 243 | distance = -distance; 244 | CGFloat minX = 0.0f - contentInset.left; 245 | 246 | if ((contentOffset.x + distance) <= minX) { 247 | distance = -contentOffset.x - contentInset.left; 248 | } 249 | 250 | translation = CGPointMake(distance, 0.0f); 251 | } break; 252 | case LXScrollingDirectionRight: { 253 | CGFloat maxX = MAX(contentSize.width, frameSize.width) - frameSize.width + contentInset.right; 254 | 255 | if ((contentOffset.x + distance) >= maxX) { 256 | distance = maxX - contentOffset.x; 257 | } 258 | 259 | translation = CGPointMake(distance, 0.0f); 260 | } break; 261 | default: { 262 | // Do nothing... 263 | } break; 264 | } 265 | 266 | self.currentViewCenter = LXS_CGPointAdd(self.currentViewCenter, translation); 267 | self.currentView.center = LXS_CGPointAdd(self.currentViewCenter, self.panTranslationInCollectionView); 268 | self.collectionView.contentOffset = LXS_CGPointAdd(contentOffset, translation); 269 | } 270 | 271 | 272 | - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer { 273 | switch(gestureRecognizer.state) { 274 | case UIGestureRecognizerStateBegan: { 275 | NSIndexPath *currentIndexPath = [self.collectionView indexPathForItemAtPoint:[gestureRecognizer locationInView:self.collectionView]]; 276 | 277 | if ([self.dataSource respondsToSelector:@selector(collectionView:canMoveItemAtIndexPath:)] && 278 | ![self.dataSource collectionView:self.collectionView canMoveItemAtIndexPath:currentIndexPath]) { 279 | return; 280 | } 281 | 282 | self.selectedItemIndexPath = currentIndexPath; 283 | 284 | if ([self.delegate respondsToSelector:@selector(collectionView:layout:willBeginDraggingItemAtIndexPath:)]) { 285 | [self.delegate collectionView:self.collectionView layout:self willBeginDraggingItemAtIndexPath:self.selectedItemIndexPath]; 286 | } 287 | 288 | UICollectionViewCell *collectionViewCell = [self.collectionView cellForItemAtIndexPath:self.selectedItemIndexPath]; 289 | 290 | self.currentView = [[UIView alloc] initWithFrame:collectionViewCell.frame]; 291 | 292 | collectionViewCell.highlighted = YES; 293 | UIImageView *highlightedImageView = [[UIImageView alloc] initWithImage:[collectionViewCell LX_rasterizedImage]]; 294 | highlightedImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 295 | highlightedImageView.alpha = 1.0f; 296 | 297 | collectionViewCell.highlighted = NO; 298 | UIImageView *imageView = [[UIImageView alloc] initWithImage:[collectionViewCell LX_rasterizedImage]]; 299 | imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 300 | imageView.alpha = 0.0f; 301 | 302 | [self.currentView addSubview:imageView]; 303 | [self.currentView addSubview:highlightedImageView]; 304 | [self.collectionView addSubview:self.currentView]; 305 | 306 | self.currentViewCenter = self.currentView.center; 307 | 308 | __weak typeof(self) weakSelf = self; 309 | [UIView 310 | animateWithDuration:0.3 311 | delay:0.0 312 | options:UIViewAnimationOptionBeginFromCurrentState 313 | animations:^{ 314 | __strong typeof(self) strongSelf = weakSelf; 315 | if (strongSelf) { 316 | strongSelf.currentView.transform = CGAffineTransformMakeScale(1.1f, 1.1f); 317 | highlightedImageView.alpha = 0.0f; 318 | imageView.alpha = 1.0f; 319 | } 320 | } 321 | completion:^(BOOL finished) { 322 | __strong typeof(self) strongSelf = weakSelf; 323 | if (strongSelf) { 324 | [highlightedImageView removeFromSuperview]; 325 | 326 | if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didBeginDraggingItemAtIndexPath:)]) { 327 | [strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didBeginDraggingItemAtIndexPath:strongSelf.selectedItemIndexPath]; 328 | } 329 | } 330 | }]; 331 | 332 | [self invalidateLayout]; 333 | } break; 334 | case UIGestureRecognizerStateCancelled: 335 | case UIGestureRecognizerStateEnded: { 336 | NSIndexPath *currentIndexPath = self.selectedItemIndexPath; 337 | 338 | if (currentIndexPath) { 339 | if ([self.delegate respondsToSelector:@selector(collectionView:layout:willEndDraggingItemAtIndexPath:)]) { 340 | [self.delegate collectionView:self.collectionView layout:self willEndDraggingItemAtIndexPath:currentIndexPath]; 341 | } 342 | 343 | self.selectedItemIndexPath = nil; 344 | self.currentViewCenter = CGPointZero; 345 | 346 | UICollectionViewLayoutAttributes *layoutAttributes = [self layoutAttributesForItemAtIndexPath:currentIndexPath]; 347 | 348 | __weak typeof(self) weakSelf = self; 349 | [UIView 350 | animateWithDuration:0.3 351 | delay:0.0 352 | options:UIViewAnimationOptionBeginFromCurrentState 353 | animations:^{ 354 | __strong typeof(self) strongSelf = weakSelf; 355 | if (strongSelf) { 356 | strongSelf.currentView.transform = CGAffineTransformMakeScale(1.0f, 1.0f); 357 | strongSelf.currentView.center = layoutAttributes.center; 358 | } 359 | } 360 | completion:^(BOOL finished) { 361 | __strong typeof(self) strongSelf = weakSelf; 362 | if (strongSelf) { 363 | [strongSelf.currentView removeFromSuperview]; 364 | strongSelf.currentView = nil; 365 | [strongSelf invalidateLayout]; 366 | 367 | if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didEndDraggingItemAtIndexPath:)]) { 368 | [strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didEndDraggingItemAtIndexPath:currentIndexPath]; 369 | } 370 | } 371 | }]; 372 | } 373 | } break; 374 | 375 | default: break; 376 | } 377 | } 378 | 379 | - (void)handlePanGesture:(UIPanGestureRecognizer *)gestureRecognizer { 380 | switch (gestureRecognizer.state) { 381 | case UIGestureRecognizerStateBegan: 382 | case UIGestureRecognizerStateChanged: { 383 | self.panTranslationInCollectionView = [gestureRecognizer translationInView:self.collectionView]; 384 | CGPoint viewCenter = self.currentView.center = LXS_CGPointAdd(self.currentViewCenter, self.panTranslationInCollectionView); 385 | 386 | [self invalidateLayoutIfNecessary]; 387 | 388 | switch (self.scrollDirection) { 389 | case UICollectionViewScrollDirectionVertical: { 390 | if (viewCenter.y < (CGRectGetMinY(self.collectionView.bounds) + self.scrollingTriggerEdgeInsets.top)) { 391 | [self setupScrollTimerInDirection:LXScrollingDirectionUp]; 392 | } else { 393 | if (viewCenter.y > (CGRectGetMaxY(self.collectionView.bounds) - self.scrollingTriggerEdgeInsets.bottom)) { 394 | [self setupScrollTimerInDirection:LXScrollingDirectionDown]; 395 | } else { 396 | [self invalidatesScrollTimer]; 397 | } 398 | } 399 | } break; 400 | case UICollectionViewScrollDirectionHorizontal: { 401 | if (viewCenter.x < (CGRectGetMinX(self.collectionView.bounds) + self.scrollingTriggerEdgeInsets.left)) { 402 | [self setupScrollTimerInDirection:LXScrollingDirectionLeft]; 403 | } else { 404 | if (viewCenter.x > (CGRectGetMaxX(self.collectionView.bounds) - self.scrollingTriggerEdgeInsets.right)) { 405 | [self setupScrollTimerInDirection:LXScrollingDirectionRight]; 406 | } else { 407 | [self invalidatesScrollTimer]; 408 | } 409 | } 410 | } break; 411 | } 412 | } break; 413 | case UIGestureRecognizerStateCancelled: 414 | case UIGestureRecognizerStateEnded: { 415 | [self invalidatesScrollTimer]; 416 | } break; 417 | default: { 418 | // Do nothing... 419 | } break; 420 | } 421 | } 422 | 423 | #pragma mark - UICollectionViewLayout overridden methods 424 | 425 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { 426 | NSArray *layoutAttributesForElementsInRect = [super layoutAttributesForElementsInRect:rect]; 427 | 428 | for (UICollectionViewLayoutAttributes *layoutAttributes in layoutAttributesForElementsInRect) { 429 | switch (layoutAttributes.representedElementCategory) { 430 | case UICollectionElementCategoryCell: { 431 | [self applyLayoutAttributes:layoutAttributes]; 432 | } break; 433 | default: { 434 | // Do nothing... 435 | } break; 436 | } 437 | } 438 | 439 | return layoutAttributesForElementsInRect; 440 | } 441 | 442 | - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath { 443 | UICollectionViewLayoutAttributes *layoutAttributes = [super layoutAttributesForItemAtIndexPath:indexPath]; 444 | 445 | switch (layoutAttributes.representedElementCategory) { 446 | case UICollectionElementCategoryCell: { 447 | [self applyLayoutAttributes:layoutAttributes]; 448 | } break; 449 | default: { 450 | // Do nothing... 451 | } break; 452 | } 453 | 454 | return layoutAttributes; 455 | } 456 | 457 | #pragma mark - UIGestureRecognizerDelegate methods 458 | 459 | - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { 460 | if ([self.panGestureRecognizer isEqual:gestureRecognizer]) { 461 | return (self.selectedItemIndexPath != nil); 462 | } 463 | return YES; 464 | } 465 | 466 | - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { 467 | if ([self.longPressGestureRecognizer isEqual:gestureRecognizer]) { 468 | return [self.panGestureRecognizer isEqual:otherGestureRecognizer]; 469 | } 470 | 471 | if ([self.panGestureRecognizer isEqual:gestureRecognizer]) { 472 | return [self.longPressGestureRecognizer isEqual:otherGestureRecognizer]; 473 | } 474 | 475 | return NO; 476 | } 477 | 478 | #pragma mark - Key-Value Observing methods 479 | 480 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { 481 | if ([keyPath isEqualToString:kLXCollectionViewKeyPath]) { 482 | if (self.collectionView != nil) { 483 | [self setupCollectionView]; 484 | } else { 485 | [self invalidatesScrollTimer]; 486 | } 487 | } 488 | } 489 | 490 | #pragma mark - Notifications 491 | 492 | - (void)handleApplicationWillResignActive:(NSNotification *)notification { 493 | self.panGestureRecognizer.enabled = NO; 494 | self.panGestureRecognizer.enabled = YES; 495 | } 496 | 497 | #pragma mark - Depreciated methods 498 | 499 | #pragma mark Starting from 0.1.0 500 | - (void)setUpGestureRecognizersOnCollectionView { 501 | // Do nothing... 502 | } 503 | 504 | @end 505 | -------------------------------------------------------------------------------- /Example/MZBookShelfDecorationView.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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Michał Zaborowski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MZBookshelfCollectionViewLayout 2 | 3 | `MZBookshelfCollectionViewLayout` is a collection view layout similar to iBooks for UICollectionView. 4 | 5 | [![](https://raw.github.com/m1entus/MZBookshelfCollectionViewLayout/master/Screens/1.png)](https://raw.github.com/m1entus/MZBookshelfCollectionViewLayout/master/Screens/1.png) 6 | 7 | ## Interface 8 | 9 | ```objective-c 10 | extern NSString *const MZBookshelfCollectionViewLayoutDecorationViewKind; 11 | 12 | @class MZBookshelfCollectionViewLayout; 13 | 14 | @protocol MZBookshelfCollectionViewLayoutDelegate 15 | @required 16 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout referenceSizeForDecorationViewForRow:(NSInteger)row inSection:(NSInteger)section; 17 | 18 | @optional 19 | - (UIOffset)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout decorationViewAdjustmentForRow:(NSInteger)row inSection:(NSInteger)section; 20 | @end 21 | 22 | @interface MZBookshelfCollectionViewLayout : UICollectionViewFlowLayout 23 | @end 24 | ``` 25 | 26 | ## Example Usage 27 | 28 | ```objective-c 29 | 30 | - (void)viewDidLoad 31 | { 32 | [super viewDidLoad]; 33 | 34 | MZBookshelfCollectionViewLayout *layout = (id)self.collectionView.collectionViewLayout; 35 | [layout registerNib:[UINib nibWithNibName:@"MZBookShelfDecorationView" bundle:nil] forDecorationViewOfKind:MZBookshelfCollectionViewLayoutDecorationViewKind]; 36 | } 37 | 38 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout referenceSizeForDecorationViewForRow:(NSInteger)row inSection:(NSInteger)section 39 | { 40 | return CGSizeMake(collectionViewLayout.collectionViewContentSize.width, 30); 41 | } 42 | 43 | - (UIOffset)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout decorationViewAdjustmentForRow:(NSInteger)row inSection:(NSInteger)section 44 | { 45 | return UIOffsetMake(0, 0); 46 | } 47 | 48 | ``` 49 | 50 | ## Contact 51 | 52 | Michał Zaborowski 53 | 54 | - http://github.com/m1entus 55 | - http://twitter.com/iMientus 56 | - http://twitter.com/inspace_io 57 | 58 | ## License 59 | 60 | MZBookshelfCollectionViewLayoutDelegate is available under the MIT license. See the LICENSE file for more info. 61 | 62 | 63 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/m1entus/mzbookshelfcollectionviewlayout/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 64 | 65 | -------------------------------------------------------------------------------- /Screens/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/m1entus/MZBookshelfCollectionViewLayout/b18ed480022e3d194487f87b0669193016bb0020/Screens/1.png -------------------------------------------------------------------------------- /Source/MZBookShelfCollectionViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // BWBookShelfCollectionViewLayout.h 3 | // BookWhiz 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | // This project is an rewritten version of grid layout by Mark Pospesel there: http://markpospesel.wordpress.com/2012/12/11/decorationviews/ 9 | 10 | #import 11 | #import "LXReorderableCollectionViewFlowLayout.h" 12 | 13 | extern NSString *const MZBookshelfCollectionViewLayoutDecorationViewKind; 14 | 15 | @class MZBookshelfCollectionViewLayout; 16 | 17 | @protocol MZBookshelfCollectionViewLayoutDelegate 18 | @required 19 | - (CGSize)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout referenceSizeForDecorationViewForRow:(NSInteger)row inSection:(NSInteger)section; 20 | 21 | @optional 22 | - (UIOffset)collectionView:(UICollectionView *)collectionView layout:(MZBookshelfCollectionViewLayout *)collectionViewLayout decorationViewAdjustmentForRow:(NSInteger)row inSection:(NSInteger)section; 23 | @end 24 | 25 | @interface MZBookshelfCollectionViewLayout : LXReorderableCollectionViewFlowLayout 26 | @end 27 | -------------------------------------------------------------------------------- /Source/MZBookShelfCollectionViewLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // BWBookShelfCollectionViewLayout.m 3 | // BookWhiz 4 | // 5 | // Created by Michał Zaborowski on 13.06.2014. 6 | // Copyright (c) 2014 Michał Zaborowski. All rights reserved. 7 | // 8 | // This project is an rewritten version of grid layout by Mark Pospesel there: http://markpospesel.wordpress.com/2012/12/11/decorationviews/ 9 | 10 | #import "MZBookshelfCollectionViewLayout.h" 11 | 12 | NSString *const MZBookshelfCollectionViewLayoutDecorationViewKind = @"MZBookshelfCollectionViewLayoutDecorationViewKind"; 13 | 14 | @interface MZBookshelfCollectionViewLayout () 15 | /// The delegate will point to collection view's delegate automatically. 16 | @property (nonatomic, weak) id delegate; 17 | @property (nonatomic, strong) NSDictionary *bookShelfRectanges; 18 | @end 19 | 20 | @implementation MZBookshelfCollectionViewLayout 21 | 22 | - (id)delegate { 23 | return (id)self.collectionView.delegate; 24 | } 25 | 26 | // Do all the calculations for determining where shelves go here 27 | - (void)prepareLayout 28 | { 29 | [super prepareLayout]; 30 | 31 | NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; 32 | 33 | if (self.scrollDirection == UICollectionViewScrollDirectionVertical) 34 | { 35 | // Calculate where shelves go in a vertical layout 36 | int sectionCount = [self.collectionView numberOfSections]; 37 | 38 | CGFloat y = 0; 39 | CGFloat availableWidth = self.collectionViewContentSize.width - (self.sectionInset.left + self.sectionInset.right); 40 | int itemsAcross = floorf((availableWidth + self.minimumInteritemSpacing) / (self.itemSize.width + self.minimumInteritemSpacing)); 41 | 42 | for (int section = 0; section < sectionCount; section++) 43 | { 44 | y += self.headerReferenceSize.height; 45 | y += self.sectionInset.top; 46 | 47 | int itemCount = [self.collectionView numberOfItemsInSection:section]; 48 | int rows = ceilf(itemCount/(float)itemsAcross); 49 | for (int row = 0; row < rows; row++) 50 | { 51 | y += self.itemSize.height; 52 | 53 | UIOffset adjustment = UIOffsetZero; 54 | 55 | if ([self.delegate respondsToSelector:@selector(collectionView:layout:decorationViewAdjustmentForRow:inSection:)]) { 56 | adjustment = [self.delegate collectionView:self.collectionView layout:self decorationViewAdjustmentForRow:row inSection:section]; 57 | } 58 | 59 | CGSize bookShelfSize = [self.delegate collectionView:self.collectionView layout:self referenceSizeForDecorationViewForRow:row inSection:section]; 60 | 61 | dictionary[[NSIndexPath indexPathForItem:row inSection:section]] = [NSValue valueWithCGRect:CGRectMake(adjustment.horizontal, y + adjustment.vertical , bookShelfSize.width, bookShelfSize.height)]; 62 | 63 | if (row < rows - 1) 64 | y += self.minimumLineSpacing; 65 | } 66 | 67 | y += self.sectionInset.bottom; 68 | y += self.footerReferenceSize.height; 69 | } 70 | } 71 | else 72 | { 73 | // Calculate where shelves go in a horizontal layout 74 | CGFloat y = self.sectionInset.top; 75 | CGFloat availableHeight = self.collectionViewContentSize.height - (self.sectionInset.top + self.sectionInset.bottom); 76 | int itemsAcross = floorf((availableHeight + self.minimumInteritemSpacing) / (self.itemSize.height + self.minimumInteritemSpacing)); 77 | CGFloat interval = ((availableHeight - self.itemSize.height) / (itemsAcross <= 1? 1 : itemsAcross - 1)) - self.itemSize.height; 78 | 79 | for (int row = 0; row < itemsAcross; row++) 80 | { 81 | CGSize bookShelfSize = [self.delegate collectionView:self.collectionView layout:self referenceSizeForDecorationViewForRow:row inSection:0]; 82 | 83 | y += self.itemSize.height; 84 | dictionary[[NSIndexPath indexPathForItem:row inSection:0]] = [NSValue valueWithCGRect:CGRectMake(0, roundf(y), bookShelfSize.width, bookShelfSize.height)]; 85 | 86 | y += interval; 87 | } 88 | 89 | 90 | } 91 | 92 | self.bookShelfRectanges = [NSDictionary dictionaryWithDictionary:dictionary]; 93 | } 94 | 95 | #pragma mark Runtime Layout Calculations 96 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect 97 | { 98 | // call super so flow layout can return default attributes for all cells, headers, and footers 99 | // NOTE: Flow layout has already taken care of the Cell view layout attributes! :) 100 | NSArray *array = [super layoutAttributesForElementsInRect:rect]; 101 | 102 | // create a mutable copy so we can add layout attributes for any shelfs that 103 | // have frames that intersect the rect the CollectionView is interested in 104 | NSMutableArray *newArray = [array mutableCopy]; 105 | 106 | // Add any decoration views (shelves) who's rect intersects with the 107 | // CGRect passed to the layout by the CollectionView 108 | 109 | [self.bookShelfRectanges enumerateKeysAndObjectsUsingBlock:^(id key, id shelfRect, BOOL *stop) { 110 | if (CGRectIntersectsRect([shelfRect CGRectValue], rect)) 111 | { 112 | UICollectionViewLayoutAttributes *shelfAttributes = 113 | [self layoutAttributesForDecorationViewOfKind:MZBookshelfCollectionViewLayoutDecorationViewKind 114 | atIndexPath:key]; 115 | [newArray addObject:shelfAttributes]; 116 | } 117 | }]; 118 | 119 | return [newArray copy]; 120 | } 121 | 122 | - (UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:(NSString *)decorationViewKind atIndexPath:(NSIndexPath *)indexPath 123 | { 124 | 125 | id shelfRect = self.bookShelfRectanges[indexPath]; 126 | 127 | // this should never happen, but just in case... 128 | if (!shelfRect) 129 | return nil; 130 | 131 | UICollectionViewLayoutAttributes *attributes = 132 | [UICollectionViewLayoutAttributes layoutAttributesForDecorationViewOfKind:decorationViewKind 133 | withIndexPath:indexPath]; 134 | attributes.frame = [shelfRect CGRectValue]; 135 | attributes.zIndex = -1; // shelves go behind other views 136 | 137 | return attributes; 138 | } 139 | 140 | @end 141 | --------------------------------------------------------------------------------