├── .gitigore ├── ChainPageCollectionView.playground ├── Contents.swift ├── contents.xcplayground └── playground.xcworkspace │ └── contents.xcworkspacedata ├── ChainPageCollectionView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata ├── xcshareddata │ └── xcschemes │ │ └── ChainPageCollectionView.xcscheme └── xcuserdata │ └── yansongli.xcuserdatad │ └── xcschemes │ ├── ChainPageCollectionViewDemo.xcscheme │ └── xcschememanagement.plist ├── ChainPageCollectionView.xcworkspace ├── contents.xcworkspacedata └── xcuserdata │ └── yansongli.xcuserdatad │ └── xcdebugger │ └── Breakpoints_v2.xcbkptlist ├── ChainPageCollectionViewDemo ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── c1.imageset │ │ ├── Contents.json │ │ └── c1.jpg │ ├── c2.imageset │ │ ├── Contents.json │ │ └── c2.jpg │ ├── c3.imageset │ │ ├── Contents.json │ │ └── c3.jpg │ ├── c4.imageset │ │ ├── Contents.json │ │ └── c4.jpg │ ├── c5.imageset │ │ ├── Contents.json │ │ └── c5.jpg │ ├── c6.imageset │ │ ├── Contents.json │ │ └── c6.jpg │ ├── facebook.imageset │ │ ├── Contents.json │ │ └── grey.jpg │ ├── firefox.imageset │ │ ├── Contents.json │ │ └── firefox.jpg │ ├── gilt.imageset │ │ ├── Contents.json │ │ └── gilt.jpg │ ├── google.imageset │ │ ├── Contents.json │ │ └── blue.jpg │ ├── indeed.imageset │ │ ├── Contents.json │ │ └── indeed.jpg │ ├── netflix.imageset │ │ ├── Contents.json │ │ └── netflix.jpg │ ├── new york time.imageset │ │ ├── Contents.json │ │ └── new york time.jpg │ ├── ritual.imageset │ │ ├── Contents.json │ │ └── ritual.jpg │ ├── sina.imageset │ │ ├── Contents.json │ │ └── sina.jpg │ ├── yahoo.imageset │ │ ├── Contents.json │ │ └── yahoo.jpg │ └── yelp.imageset │ │ ├── Contents.json │ │ └── street.jpg ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── BaseCardCollectionCell.swift ├── ImageCardCollectionCell.swift ├── Info.plist ├── UIColorExtension.swift └── ViewController.swift ├── ChainPageCollectionViewTests ├── ChainPageCollectionViewTests.swift └── Info.plist ├── Images ├── ChainPage.png ├── new1.gif └── new2.gif ├── LICENSE ├── Metadata └── ChainPageCollectionView.podspec ├── README.md └── Sources ├── CentralCardLayout.swift ├── ChainCollectionViewProtocol.swift ├── ChainPageCollectionView.h ├── ChainPageCollectionView.swift ├── EdgeCardLayout.swift └── Info.plist /.gitigore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /ChainPageCollectionView.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import UIKit 4 | 5 | var str = "Hello, playground" 6 | -------------------------------------------------------------------------------- /ChainPageCollectionView.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /ChainPageCollectionView.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ChainPageCollectionView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0E1C36781F24FA8900D6FFE0 /* ChainPageCollectionView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0ED42C281F24506D009FCF88 /* ChainPageCollectionView.framework */; }; 11 | 0E1C367D1F24FC2000D6FFE0 /* ChainPageCollectionView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0ED42C281F24506D009FCF88 /* ChainPageCollectionView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | 0E1C36801F2542F200D6FFE0 /* BaseCardCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1C367F1F2542F200D6FFE0 /* BaseCardCollectionCell.swift */; }; 13 | 0E1C36821F25431C00D6FFE0 /* UIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1C36811F25431C00D6FFE0 /* UIColorExtension.swift */; }; 14 | 0E1C36841F25446500D6FFE0 /* ImageCardCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1C36831F25446500D6FFE0 /* ImageCardCollectionCell.swift */; }; 15 | 0ED42C321F24506D009FCF88 /* ChainPageCollectionView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0ED42C281F24506D009FCF88 /* ChainPageCollectionView.framework */; }; 16 | 0ED42C371F24506D009FCF88 /* ChainPageCollectionViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED42C361F24506D009FCF88 /* ChainPageCollectionViewTests.swift */; }; 17 | 0ED42C461F24543E009FCF88 /* ChainPageCollectionView.h in Headers */ = {isa = PBXBuildFile; fileRef = 0ED42C451F24543E009FCF88 /* ChainPageCollectionView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 18 | 0ED42C511F2457CF009FCF88 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED42C501F2457CF009FCF88 /* AppDelegate.swift */; }; 19 | 0ED42C531F2457CF009FCF88 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED42C521F2457CF009FCF88 /* ViewController.swift */; }; 20 | 0ED42C561F2457CF009FCF88 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0ED42C541F2457CF009FCF88 /* Main.storyboard */; }; 21 | 0ED42C581F2457CF009FCF88 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0ED42C571F2457CF009FCF88 /* Assets.xcassets */; }; 22 | 0ED42C5B1F2457CF009FCF88 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0ED42C591F2457CF009FCF88 /* LaunchScreen.storyboard */; }; 23 | 0ED42C671F245914009FCF88 /* CentralCardLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED42C611F245914009FCF88 /* CentralCardLayout.swift */; }; 24 | 0ED42C681F245914009FCF88 /* ChainCollectionViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED42C621F245914009FCF88 /* ChainCollectionViewProtocol.swift */; }; 25 | 0ED42C691F245914009FCF88 /* ChainPageCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED42C631F245914009FCF88 /* ChainPageCollectionView.swift */; }; 26 | 0ED42C6A1F245914009FCF88 /* EdgeCardLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED42C641F245914009FCF88 /* EdgeCardLayout.swift */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXContainerItemProxy section */ 30 | 0ED42C331F24506D009FCF88 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 0ED42C1F1F24506D009FCF88 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 0ED42C271F24506D009FCF88; 35 | remoteInfo = ChainPageCollectionView; 36 | }; 37 | 0ED42C6C1F245953009FCF88 /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = 0ED42C1F1F24506D009FCF88 /* Project object */; 40 | proxyType = 1; 41 | remoteGlobalIDString = 0ED42C271F24506D009FCF88; 42 | remoteInfo = ChainPageCollectionView; 43 | }; 44 | /* End PBXContainerItemProxy section */ 45 | 46 | /* Begin PBXCopyFilesBuildPhase section */ 47 | 0E1C367E1F24FC2000D6FFE0 /* Embed Frameworks */ = { 48 | isa = PBXCopyFilesBuildPhase; 49 | buildActionMask = 2147483647; 50 | dstPath = ""; 51 | dstSubfolderSpec = 10; 52 | files = ( 53 | 0E1C367D1F24FC2000D6FFE0 /* ChainPageCollectionView.framework in Embed Frameworks */, 54 | ); 55 | name = "Embed Frameworks"; 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXCopyFilesBuildPhase section */ 59 | 60 | /* Begin PBXFileReference section */ 61 | 0E1C36581F24D51400D6FFE0 /* ChainPageCollectionView.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ChainPageCollectionView.podspec; sourceTree = ""; }; 62 | 0E1C367F1F2542F200D6FFE0 /* BaseCardCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseCardCollectionCell.swift; sourceTree = ""; }; 63 | 0E1C36811F25431C00D6FFE0 /* UIColorExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIColorExtension.swift; sourceTree = ""; }; 64 | 0E1C36831F25446500D6FFE0 /* ImageCardCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCardCollectionCell.swift; sourceTree = ""; }; 65 | 0ED42C281F24506D009FCF88 /* ChainPageCollectionView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ChainPageCollectionView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | 0ED42C311F24506D009FCF88 /* ChainPageCollectionViewTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChainPageCollectionViewTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 67 | 0ED42C361F24506D009FCF88 /* ChainPageCollectionViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChainPageCollectionViewTests.swift; sourceTree = ""; }; 68 | 0ED42C381F24506D009FCF88 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 69 | 0ED42C431F245348009FCF88 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | 0ED42C451F24543E009FCF88 /* ChainPageCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChainPageCollectionView.h; sourceTree = ""; }; 71 | 0ED42C4E1F2457CF009FCF88 /* ChainPageCollectionViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChainPageCollectionViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | 0ED42C501F2457CF009FCF88 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 73 | 0ED42C521F2457CF009FCF88 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 74 | 0ED42C551F2457CF009FCF88 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 75 | 0ED42C571F2457CF009FCF88 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 76 | 0ED42C5A1F2457CF009FCF88 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 77 | 0ED42C5C1F2457CF009FCF88 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 78 | 0ED42C611F245914009FCF88 /* CentralCardLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CentralCardLayout.swift; sourceTree = ""; }; 79 | 0ED42C621F245914009FCF88 /* ChainCollectionViewProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChainCollectionViewProtocol.swift; sourceTree = ""; }; 80 | 0ED42C631F245914009FCF88 /* ChainPageCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChainPageCollectionView.swift; sourceTree = ""; }; 81 | 0ED42C641F245914009FCF88 /* EdgeCardLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EdgeCardLayout.swift; sourceTree = ""; }; 82 | /* End PBXFileReference section */ 83 | 84 | /* Begin PBXFrameworksBuildPhase section */ 85 | 0ED42C241F24506D009FCF88 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | 0ED42C2E1F24506D009FCF88 /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | 0ED42C321F24506D009FCF88 /* ChainPageCollectionView.framework in Frameworks */, 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | 0ED42C4B1F2457CF009FCF88 /* Frameworks */ = { 101 | isa = PBXFrameworksBuildPhase; 102 | buildActionMask = 2147483647; 103 | files = ( 104 | 0E1C36781F24FA8900D6FFE0 /* ChainPageCollectionView.framework in Frameworks */, 105 | ); 106 | runOnlyForDeploymentPostprocessing = 0; 107 | }; 108 | /* End PBXFrameworksBuildPhase section */ 109 | 110 | /* Begin PBXGroup section */ 111 | 0ED42C1E1F24506D009FCF88 = { 112 | isa = PBXGroup; 113 | children = ( 114 | 0ED42C471F24560B009FCF88 /* Metadata */, 115 | 0ED42C421F24530E009FCF88 /* Sources */, 116 | 0ED42C351F24506D009FCF88 /* ChainPageCollectionViewTests */, 117 | 0ED42C4F1F2457CF009FCF88 /* ChainPageCollectionViewDemo */, 118 | 0ED42C291F24506D009FCF88 /* Products */, 119 | ); 120 | sourceTree = ""; 121 | }; 122 | 0ED42C291F24506D009FCF88 /* Products */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 0ED42C281F24506D009FCF88 /* ChainPageCollectionView.framework */, 126 | 0ED42C311F24506D009FCF88 /* ChainPageCollectionViewTests.xctest */, 127 | 0ED42C4E1F2457CF009FCF88 /* ChainPageCollectionViewDemo.app */, 128 | ); 129 | name = Products; 130 | sourceTree = ""; 131 | }; 132 | 0ED42C351F24506D009FCF88 /* ChainPageCollectionViewTests */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 0ED42C361F24506D009FCF88 /* ChainPageCollectionViewTests.swift */, 136 | 0ED42C381F24506D009FCF88 /* Info.plist */, 137 | ); 138 | path = ChainPageCollectionViewTests; 139 | sourceTree = ""; 140 | }; 141 | 0ED42C421F24530E009FCF88 /* Sources */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 0ED42C611F245914009FCF88 /* CentralCardLayout.swift */, 145 | 0ED42C621F245914009FCF88 /* ChainCollectionViewProtocol.swift */, 146 | 0ED42C631F245914009FCF88 /* ChainPageCollectionView.swift */, 147 | 0ED42C641F245914009FCF88 /* EdgeCardLayout.swift */, 148 | 0ED42C451F24543E009FCF88 /* ChainPageCollectionView.h */, 149 | 0ED42C431F245348009FCF88 /* Info.plist */, 150 | ); 151 | path = Sources; 152 | sourceTree = ""; 153 | }; 154 | 0ED42C471F24560B009FCF88 /* Metadata */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | 0E1C36581F24D51400D6FFE0 /* ChainPageCollectionView.podspec */, 158 | ); 159 | path = Metadata; 160 | sourceTree = ""; 161 | }; 162 | 0ED42C4F1F2457CF009FCF88 /* ChainPageCollectionViewDemo */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | 0ED42C501F2457CF009FCF88 /* AppDelegate.swift */, 166 | 0E1C367F1F2542F200D6FFE0 /* BaseCardCollectionCell.swift */, 167 | 0E1C36831F25446500D6FFE0 /* ImageCardCollectionCell.swift */, 168 | 0E1C36811F25431C00D6FFE0 /* UIColorExtension.swift */, 169 | 0ED42C521F2457CF009FCF88 /* ViewController.swift */, 170 | 0ED42C541F2457CF009FCF88 /* Main.storyboard */, 171 | 0ED42C571F2457CF009FCF88 /* Assets.xcassets */, 172 | 0ED42C591F2457CF009FCF88 /* LaunchScreen.storyboard */, 173 | 0ED42C5C1F2457CF009FCF88 /* Info.plist */, 174 | ); 175 | path = ChainPageCollectionViewDemo; 176 | sourceTree = ""; 177 | }; 178 | /* End PBXGroup section */ 179 | 180 | /* Begin PBXHeadersBuildPhase section */ 181 | 0ED42C251F24506D009FCF88 /* Headers */ = { 182 | isa = PBXHeadersBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 0ED42C461F24543E009FCF88 /* ChainPageCollectionView.h in Headers */, 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXHeadersBuildPhase section */ 190 | 191 | /* Begin PBXNativeTarget section */ 192 | 0ED42C271F24506D009FCF88 /* ChainPageCollectionView */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = 0ED42C3C1F24506D009FCF88 /* Build configuration list for PBXNativeTarget "ChainPageCollectionView" */; 195 | buildPhases = ( 196 | 0ED42C231F24506D009FCF88 /* Sources */, 197 | 0ED42C241F24506D009FCF88 /* Frameworks */, 198 | 0ED42C251F24506D009FCF88 /* Headers */, 199 | 0ED42C261F24506D009FCF88 /* Resources */, 200 | ); 201 | buildRules = ( 202 | ); 203 | dependencies = ( 204 | ); 205 | name = ChainPageCollectionView; 206 | productName = ChainPageCollectionView; 207 | productReference = 0ED42C281F24506D009FCF88 /* ChainPageCollectionView.framework */; 208 | productType = "com.apple.product-type.framework"; 209 | }; 210 | 0ED42C301F24506D009FCF88 /* ChainPageCollectionViewTests */ = { 211 | isa = PBXNativeTarget; 212 | buildConfigurationList = 0ED42C3F1F24506D009FCF88 /* Build configuration list for PBXNativeTarget "ChainPageCollectionViewTests" */; 213 | buildPhases = ( 214 | 0ED42C2D1F24506D009FCF88 /* Sources */, 215 | 0ED42C2E1F24506D009FCF88 /* Frameworks */, 216 | 0ED42C2F1F24506D009FCF88 /* Resources */, 217 | ); 218 | buildRules = ( 219 | ); 220 | dependencies = ( 221 | 0ED42C341F24506D009FCF88 /* PBXTargetDependency */, 222 | ); 223 | name = ChainPageCollectionViewTests; 224 | productName = ChainPageCollectionViewTests; 225 | productReference = 0ED42C311F24506D009FCF88 /* ChainPageCollectionViewTests.xctest */; 226 | productType = "com.apple.product-type.bundle.unit-test"; 227 | }; 228 | 0ED42C4D1F2457CF009FCF88 /* ChainPageCollectionViewDemo */ = { 229 | isa = PBXNativeTarget; 230 | buildConfigurationList = 0ED42C5D1F2457CF009FCF88 /* Build configuration list for PBXNativeTarget "ChainPageCollectionViewDemo" */; 231 | buildPhases = ( 232 | 0ED42C4A1F2457CF009FCF88 /* Sources */, 233 | 0ED42C4B1F2457CF009FCF88 /* Frameworks */, 234 | 0ED42C4C1F2457CF009FCF88 /* Resources */, 235 | 0E1C367E1F24FC2000D6FFE0 /* Embed Frameworks */, 236 | ); 237 | buildRules = ( 238 | ); 239 | dependencies = ( 240 | 0ED42C6D1F245953009FCF88 /* PBXTargetDependency */, 241 | ); 242 | name = ChainPageCollectionViewDemo; 243 | productName = ChainPageCollectionViewDemo; 244 | productReference = 0ED42C4E1F2457CF009FCF88 /* ChainPageCollectionViewDemo.app */; 245 | productType = "com.apple.product-type.application"; 246 | }; 247 | /* End PBXNativeTarget section */ 248 | 249 | /* Begin PBXProject section */ 250 | 0ED42C1F1F24506D009FCF88 /* Project object */ = { 251 | isa = PBXProject; 252 | attributes = { 253 | LastSwiftUpdateCheck = 0830; 254 | LastUpgradeCheck = 0830; 255 | ORGANIZATIONNAME = "yansong li"; 256 | TargetAttributes = { 257 | 0ED42C271F24506D009FCF88 = { 258 | CreatedOnToolsVersion = 8.3.2; 259 | DevelopmentTeam = 655YRAVK2U; 260 | LastSwiftMigration = 0830; 261 | ProvisioningStyle = Automatic; 262 | }; 263 | 0ED42C301F24506D009FCF88 = { 264 | CreatedOnToolsVersion = 8.3.2; 265 | DevelopmentTeam = 655YRAVK2U; 266 | ProvisioningStyle = Automatic; 267 | }; 268 | 0ED42C4D1F2457CF009FCF88 = { 269 | CreatedOnToolsVersion = 8.3.2; 270 | ProvisioningStyle = Automatic; 271 | }; 272 | }; 273 | }; 274 | buildConfigurationList = 0ED42C221F24506D009FCF88 /* Build configuration list for PBXProject "ChainPageCollectionView" */; 275 | compatibilityVersion = "Xcode 3.2"; 276 | developmentRegion = English; 277 | hasScannedForEncodings = 0; 278 | knownRegions = ( 279 | en, 280 | Base, 281 | ); 282 | mainGroup = 0ED42C1E1F24506D009FCF88; 283 | productRefGroup = 0ED42C291F24506D009FCF88 /* Products */; 284 | projectDirPath = ""; 285 | projectRoot = ""; 286 | targets = ( 287 | 0ED42C271F24506D009FCF88 /* ChainPageCollectionView */, 288 | 0ED42C301F24506D009FCF88 /* ChainPageCollectionViewTests */, 289 | 0ED42C4D1F2457CF009FCF88 /* ChainPageCollectionViewDemo */, 290 | ); 291 | }; 292 | /* End PBXProject section */ 293 | 294 | /* Begin PBXResourcesBuildPhase section */ 295 | 0ED42C261F24506D009FCF88 /* Resources */ = { 296 | isa = PBXResourcesBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | ); 300 | runOnlyForDeploymentPostprocessing = 0; 301 | }; 302 | 0ED42C2F1F24506D009FCF88 /* Resources */ = { 303 | isa = PBXResourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | 0ED42C4C1F2457CF009FCF88 /* Resources */ = { 310 | isa = PBXResourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | 0ED42C5B1F2457CF009FCF88 /* LaunchScreen.storyboard in Resources */, 314 | 0ED42C581F2457CF009FCF88 /* Assets.xcassets in Resources */, 315 | 0ED42C561F2457CF009FCF88 /* Main.storyboard in Resources */, 316 | ); 317 | runOnlyForDeploymentPostprocessing = 0; 318 | }; 319 | /* End PBXResourcesBuildPhase section */ 320 | 321 | /* Begin PBXSourcesBuildPhase section */ 322 | 0ED42C231F24506D009FCF88 /* Sources */ = { 323 | isa = PBXSourcesBuildPhase; 324 | buildActionMask = 2147483647; 325 | files = ( 326 | 0ED42C681F245914009FCF88 /* ChainCollectionViewProtocol.swift in Sources */, 327 | 0ED42C671F245914009FCF88 /* CentralCardLayout.swift in Sources */, 328 | 0ED42C691F245914009FCF88 /* ChainPageCollectionView.swift in Sources */, 329 | 0ED42C6A1F245914009FCF88 /* EdgeCardLayout.swift in Sources */, 330 | ); 331 | runOnlyForDeploymentPostprocessing = 0; 332 | }; 333 | 0ED42C2D1F24506D009FCF88 /* Sources */ = { 334 | isa = PBXSourcesBuildPhase; 335 | buildActionMask = 2147483647; 336 | files = ( 337 | 0ED42C371F24506D009FCF88 /* ChainPageCollectionViewTests.swift in Sources */, 338 | ); 339 | runOnlyForDeploymentPostprocessing = 0; 340 | }; 341 | 0ED42C4A1F2457CF009FCF88 /* Sources */ = { 342 | isa = PBXSourcesBuildPhase; 343 | buildActionMask = 2147483647; 344 | files = ( 345 | 0ED42C531F2457CF009FCF88 /* ViewController.swift in Sources */, 346 | 0ED42C511F2457CF009FCF88 /* AppDelegate.swift in Sources */, 347 | 0E1C36841F25446500D6FFE0 /* ImageCardCollectionCell.swift in Sources */, 348 | 0E1C36801F2542F200D6FFE0 /* BaseCardCollectionCell.swift in Sources */, 349 | 0E1C36821F25431C00D6FFE0 /* UIColorExtension.swift in Sources */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | /* End PBXSourcesBuildPhase section */ 354 | 355 | /* Begin PBXTargetDependency section */ 356 | 0ED42C341F24506D009FCF88 /* PBXTargetDependency */ = { 357 | isa = PBXTargetDependency; 358 | target = 0ED42C271F24506D009FCF88 /* ChainPageCollectionView */; 359 | targetProxy = 0ED42C331F24506D009FCF88 /* PBXContainerItemProxy */; 360 | }; 361 | 0ED42C6D1F245953009FCF88 /* PBXTargetDependency */ = { 362 | isa = PBXTargetDependency; 363 | target = 0ED42C271F24506D009FCF88 /* ChainPageCollectionView */; 364 | targetProxy = 0ED42C6C1F245953009FCF88 /* PBXContainerItemProxy */; 365 | }; 366 | /* End PBXTargetDependency section */ 367 | 368 | /* Begin PBXVariantGroup section */ 369 | 0ED42C541F2457CF009FCF88 /* Main.storyboard */ = { 370 | isa = PBXVariantGroup; 371 | children = ( 372 | 0ED42C551F2457CF009FCF88 /* Base */, 373 | ); 374 | name = Main.storyboard; 375 | sourceTree = ""; 376 | }; 377 | 0ED42C591F2457CF009FCF88 /* LaunchScreen.storyboard */ = { 378 | isa = PBXVariantGroup; 379 | children = ( 380 | 0ED42C5A1F2457CF009FCF88 /* Base */, 381 | ); 382 | name = LaunchScreen.storyboard; 383 | sourceTree = ""; 384 | }; 385 | /* End PBXVariantGroup section */ 386 | 387 | /* Begin XCBuildConfiguration section */ 388 | 0ED42C3A1F24506D009FCF88 /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | ALWAYS_SEARCH_USER_PATHS = NO; 392 | CLANG_ANALYZER_NONNULL = YES; 393 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 394 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 395 | CLANG_CXX_LIBRARY = "libc++"; 396 | CLANG_ENABLE_MODULES = YES; 397 | CLANG_ENABLE_OBJC_ARC = YES; 398 | CLANG_WARN_BOOL_CONVERSION = YES; 399 | CLANG_WARN_CONSTANT_CONVERSION = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INFINITE_RECURSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 407 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 408 | CLANG_WARN_UNREACHABLE_CODE = YES; 409 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 410 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 411 | COPY_PHASE_STRIP = NO; 412 | CURRENT_PROJECT_VERSION = 1; 413 | DEBUG_INFORMATION_FORMAT = dwarf; 414 | ENABLE_STRICT_OBJC_MSGSEND = YES; 415 | ENABLE_TESTABILITY = YES; 416 | GCC_C_LANGUAGE_STANDARD = gnu99; 417 | GCC_DYNAMIC_NO_PIC = NO; 418 | GCC_NO_COMMON_BLOCKS = YES; 419 | GCC_OPTIMIZATION_LEVEL = 0; 420 | GCC_PREPROCESSOR_DEFINITIONS = ( 421 | "DEBUG=1", 422 | "$(inherited)", 423 | ); 424 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 425 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 426 | GCC_WARN_UNDECLARED_SELECTOR = YES; 427 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 428 | GCC_WARN_UNUSED_FUNCTION = YES; 429 | GCC_WARN_UNUSED_VARIABLE = YES; 430 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 431 | MTL_ENABLE_DEBUG_INFO = YES; 432 | ONLY_ACTIVE_ARCH = YES; 433 | SDKROOT = iphoneos; 434 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 435 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 436 | TARGETED_DEVICE_FAMILY = "1,2"; 437 | VERSIONING_SYSTEM = "apple-generic"; 438 | VERSION_INFO_PREFIX = ""; 439 | }; 440 | name = Debug; 441 | }; 442 | 0ED42C3B1F24506D009FCF88 /* Release */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | ALWAYS_SEARCH_USER_PATHS = NO; 446 | CLANG_ANALYZER_NONNULL = YES; 447 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 448 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 449 | CLANG_CXX_LIBRARY = "libc++"; 450 | CLANG_ENABLE_MODULES = YES; 451 | CLANG_ENABLE_OBJC_ARC = YES; 452 | CLANG_WARN_BOOL_CONVERSION = YES; 453 | CLANG_WARN_CONSTANT_CONVERSION = YES; 454 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 455 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 456 | CLANG_WARN_EMPTY_BODY = YES; 457 | CLANG_WARN_ENUM_CONVERSION = YES; 458 | CLANG_WARN_INFINITE_RECURSION = YES; 459 | CLANG_WARN_INT_CONVERSION = YES; 460 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 461 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 462 | CLANG_WARN_UNREACHABLE_CODE = YES; 463 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 464 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 465 | COPY_PHASE_STRIP = NO; 466 | CURRENT_PROJECT_VERSION = 1; 467 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 468 | ENABLE_NS_ASSERTIONS = NO; 469 | ENABLE_STRICT_OBJC_MSGSEND = YES; 470 | GCC_C_LANGUAGE_STANDARD = gnu99; 471 | GCC_NO_COMMON_BLOCKS = YES; 472 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 473 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 474 | GCC_WARN_UNDECLARED_SELECTOR = YES; 475 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 476 | GCC_WARN_UNUSED_FUNCTION = YES; 477 | GCC_WARN_UNUSED_VARIABLE = YES; 478 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 479 | MTL_ENABLE_DEBUG_INFO = NO; 480 | SDKROOT = iphoneos; 481 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 482 | TARGETED_DEVICE_FAMILY = "1,2"; 483 | VALIDATE_PRODUCT = YES; 484 | VERSIONING_SYSTEM = "apple-generic"; 485 | VERSION_INFO_PREFIX = ""; 486 | }; 487 | name = Release; 488 | }; 489 | 0ED42C3D1F24506D009FCF88 /* Debug */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | CLANG_ENABLE_MODULES = YES; 493 | CODE_SIGN_IDENTITY = ""; 494 | DEFINES_MODULE = YES; 495 | DEVELOPMENT_TEAM = 655YRAVK2U; 496 | DYLIB_COMPATIBILITY_VERSION = 1; 497 | DYLIB_CURRENT_VERSION = 1; 498 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 499 | INFOPLIST_FILE = Sources/Info.plist; 500 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 501 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 502 | PRODUCT_BUNDLE_IDENTIFIER = com.yansong.ChainPageCollectionView; 503 | PRODUCT_NAME = "$(TARGET_NAME)"; 504 | SKIP_INSTALL = YES; 505 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 506 | SWIFT_VERSION = 3.0; 507 | }; 508 | name = Debug; 509 | }; 510 | 0ED42C3E1F24506D009FCF88 /* Release */ = { 511 | isa = XCBuildConfiguration; 512 | buildSettings = { 513 | CLANG_ENABLE_MODULES = YES; 514 | CODE_SIGN_IDENTITY = ""; 515 | DEFINES_MODULE = YES; 516 | DEVELOPMENT_TEAM = 655YRAVK2U; 517 | DYLIB_COMPATIBILITY_VERSION = 1; 518 | DYLIB_CURRENT_VERSION = 1; 519 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 520 | INFOPLIST_FILE = Sources/Info.plist; 521 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 522 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 523 | PRODUCT_BUNDLE_IDENTIFIER = com.yansong.ChainPageCollectionView; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | SKIP_INSTALL = YES; 526 | SWIFT_VERSION = 3.0; 527 | }; 528 | name = Release; 529 | }; 530 | 0ED42C401F24506D009FCF88 /* Debug */ = { 531 | isa = XCBuildConfiguration; 532 | buildSettings = { 533 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 534 | DEVELOPMENT_TEAM = 655YRAVK2U; 535 | INFOPLIST_FILE = ChainPageCollectionViewTests/Info.plist; 536 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 537 | PRODUCT_BUNDLE_IDENTIFIER = com.yansong.ChainPageCollectionViewTests; 538 | PRODUCT_NAME = "$(TARGET_NAME)"; 539 | SWIFT_VERSION = 3.0; 540 | }; 541 | name = Debug; 542 | }; 543 | 0ED42C411F24506D009FCF88 /* Release */ = { 544 | isa = XCBuildConfiguration; 545 | buildSettings = { 546 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 547 | DEVELOPMENT_TEAM = 655YRAVK2U; 548 | INFOPLIST_FILE = ChainPageCollectionViewTests/Info.plist; 549 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 550 | PRODUCT_BUNDLE_IDENTIFIER = com.yansong.ChainPageCollectionViewTests; 551 | PRODUCT_NAME = "$(TARGET_NAME)"; 552 | SWIFT_VERSION = 3.0; 553 | }; 554 | name = Release; 555 | }; 556 | 0ED42C5E1F2457CF009FCF88 /* Debug */ = { 557 | isa = XCBuildConfiguration; 558 | buildSettings = { 559 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 560 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 561 | DEVELOPMENT_TEAM = ""; 562 | INFOPLIST_FILE = ChainPageCollectionViewDemo/Info.plist; 563 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 564 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 565 | PRODUCT_BUNDLE_IDENTIFIER = com.yansong.ChainPageCollectionViewDemo; 566 | PRODUCT_NAME = "$(TARGET_NAME)"; 567 | SWIFT_VERSION = 3.0; 568 | }; 569 | name = Debug; 570 | }; 571 | 0ED42C5F1F2457CF009FCF88 /* Release */ = { 572 | isa = XCBuildConfiguration; 573 | buildSettings = { 574 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 575 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 576 | DEVELOPMENT_TEAM = ""; 577 | INFOPLIST_FILE = ChainPageCollectionViewDemo/Info.plist; 578 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 579 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 580 | PRODUCT_BUNDLE_IDENTIFIER = com.yansong.ChainPageCollectionViewDemo; 581 | PRODUCT_NAME = "$(TARGET_NAME)"; 582 | SWIFT_VERSION = 3.0; 583 | }; 584 | name = Release; 585 | }; 586 | /* End XCBuildConfiguration section */ 587 | 588 | /* Begin XCConfigurationList section */ 589 | 0ED42C221F24506D009FCF88 /* Build configuration list for PBXProject "ChainPageCollectionView" */ = { 590 | isa = XCConfigurationList; 591 | buildConfigurations = ( 592 | 0ED42C3A1F24506D009FCF88 /* Debug */, 593 | 0ED42C3B1F24506D009FCF88 /* Release */, 594 | ); 595 | defaultConfigurationIsVisible = 0; 596 | defaultConfigurationName = Release; 597 | }; 598 | 0ED42C3C1F24506D009FCF88 /* Build configuration list for PBXNativeTarget "ChainPageCollectionView" */ = { 599 | isa = XCConfigurationList; 600 | buildConfigurations = ( 601 | 0ED42C3D1F24506D009FCF88 /* Debug */, 602 | 0ED42C3E1F24506D009FCF88 /* Release */, 603 | ); 604 | defaultConfigurationIsVisible = 0; 605 | defaultConfigurationName = Release; 606 | }; 607 | 0ED42C3F1F24506D009FCF88 /* Build configuration list for PBXNativeTarget "ChainPageCollectionViewTests" */ = { 608 | isa = XCConfigurationList; 609 | buildConfigurations = ( 610 | 0ED42C401F24506D009FCF88 /* Debug */, 611 | 0ED42C411F24506D009FCF88 /* Release */, 612 | ); 613 | defaultConfigurationIsVisible = 0; 614 | defaultConfigurationName = Release; 615 | }; 616 | 0ED42C5D1F2457CF009FCF88 /* Build configuration list for PBXNativeTarget "ChainPageCollectionViewDemo" */ = { 617 | isa = XCConfigurationList; 618 | buildConfigurations = ( 619 | 0ED42C5E1F2457CF009FCF88 /* Debug */, 620 | 0ED42C5F1F2457CF009FCF88 /* Release */, 621 | ); 622 | defaultConfigurationIsVisible = 0; 623 | defaultConfigurationName = Release; 624 | }; 625 | /* End XCConfigurationList section */ 626 | }; 627 | rootObject = 0ED42C1F1F24506D009FCF88 /* Project object */; 628 | } 629 | -------------------------------------------------------------------------------- /ChainPageCollectionView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ChainPageCollectionView.xcodeproj/xcshareddata/xcschemes/ChainPageCollectionView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /ChainPageCollectionView.xcodeproj/xcuserdata/yansongli.xcuserdatad/xcschemes/ChainPageCollectionViewDemo.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 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ChainPageCollectionView.xcodeproj/xcuserdata/yansongli.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ChainPageCollectionView.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | ChainPageCollectionViewDemo.xcscheme 13 | 14 | orderHint 15 | 1 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 0ED42C271F24506D009FCF88 21 | 22 | primary 23 | 24 | 25 | 0ED42C301F24506D009FCF88 26 | 27 | primary 28 | 29 | 30 | 0ED42C4D1F2457CF009FCF88 31 | 32 | primary 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ChainPageCollectionView.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ChainPageCollectionView.xcworkspace/xcuserdata/yansongli.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 18 | 30 | 31 | 32 | 34 | 46 | 47 | 48 | 50 | 62 | 63 | 64 | 66 | 78 | 79 | 93 | 94 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ChainPageCollectionViewDemo 4 | // 5 | // Created by yansong li on 2017-07-23. 6 | // Copyright © 2017 yansong li. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/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 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c1.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c1.imageset/c1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/c1.imageset/c1.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c2.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c2.imageset/c2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/c2.imageset/c2.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c3.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c3.imageset/c3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/c3.imageset/c3.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c4.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c4.imageset/c4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/c4.imageset/c4.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c5.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c5.imageset/c5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/c5.imageset/c5.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c6.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "c6.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/c6.imageset/c6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/c6.imageset/c6.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/facebook.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "grey.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/facebook.imageset/grey.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/facebook.imageset/grey.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/firefox.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "firefox.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/firefox.imageset/firefox.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/firefox.imageset/firefox.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/gilt.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "gilt.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/gilt.imageset/gilt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/gilt.imageset/gilt.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/google.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "blue.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/google.imageset/blue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/google.imageset/blue.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/indeed.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "indeed.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/indeed.imageset/indeed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/indeed.imageset/indeed.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/netflix.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "netflix.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/netflix.imageset/netflix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/netflix.imageset/netflix.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/new york time.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "new york time.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/new york time.imageset/new york time.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/new york time.imageset/new york time.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/ritual.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "ritual.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/ritual.imageset/ritual.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/ritual.imageset/ritual.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/sina.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "sina.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/sina.imageset/sina.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/sina.imageset/sina.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/yahoo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "yahoo.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/yahoo.imageset/yahoo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/yahoo.imageset/yahoo.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/yelp.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "street.jpg", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/Assets.xcassets/yelp.imageset/street.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/ChainPageCollectionViewDemo/Assets.xcassets/yelp.imageset/street.jpg -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/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 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/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 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/BaseCardCollectionCell.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Yansong Li 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish, 15 | * distribute, sublicense, create a derivative work, and/or sell copies of the 16 | * Software in any work that is designed, intended, or marketed for pedagogical or 17 | * instructional purposes related to programming, coding, application development, 18 | * or information technology. Permission for such use, copying, modification, 19 | * merger, publication, distribution, sublicensing, creation of derivative works, 20 | * or sale is expressly withheld. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | 31 | import UIKit 32 | 33 | /// The base card collection cell. 34 | open class BaseCardCollectionCell: UICollectionViewCell { 35 | 36 | open var textLabel: UILabel! 37 | 38 | public override init(frame: CGRect) { 39 | super.init(frame: frame) 40 | self.layer.cornerRadius = 6.0 41 | textLabel = UILabel() 42 | textLabel.numberOfLines = 0 43 | textLabel.layer.cornerRadius = 6.0 44 | textLabel.clipsToBounds = true 45 | textLabel.translatesAutoresizingMaskIntoConstraints = false 46 | textLabel.textAlignment = .center 47 | textLabel.textColor = UIColor.white 48 | textLabel.font = UIFont.systemFont(ofSize: 18.0) 49 | self.addSubview(textLabel) 50 | textLabel.backgroundColor = UIColor.randomColor() 51 | buildConstraint() 52 | } 53 | 54 | required public init?(coder aDecoder: NSCoder) { 55 | fatalError("init(coder:) has not been implemented") 56 | } 57 | 58 | private func buildConstraint() { 59 | textLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor).isActive = true 60 | textLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor).isActive = true 61 | textLabel.topAnchor.constraint(equalTo: self.topAnchor).isActive = true 62 | textLabel.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/ImageCardCollectionCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageCardCollectionCell.swift 3 | // ChainPageCollectionView 4 | // 5 | // Created by yansong li on 2017-07-23. 6 | // Copyright © 2017 yansong li. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | /// The base card collection cell. 12 | public class ImageCardCollectionViewCell: UICollectionViewCell { 13 | 14 | public var backGroundImageView: UIImageView! 15 | 16 | public override init(frame: CGRect) { 17 | super.init(frame: frame) 18 | self.layer.shadowColor = UIColor.black.cgColor 19 | self.layer.shadowOffset = CGSize(width: 1, height: 1) 20 | self.layer.shadowOpacity = 0.7 21 | self.layer.shadowRadius = 4.0 22 | backGroundImageView = UIImageView() 23 | backGroundImageView.contentMode = .scaleAspectFill 24 | backGroundImageView.translatesAutoresizingMaskIntoConstraints = false 25 | self.contentView.layer.masksToBounds = true 26 | self.contentView.layer.cornerRadius = 8.0 27 | self.contentView.addSubview(backGroundImageView) 28 | buildConstraint() 29 | } 30 | 31 | required public init?(coder aDecoder: NSCoder) { 32 | fatalError("init(coder:) has not been implemented") 33 | } 34 | 35 | // MARK: Private 36 | private func buildConstraint() { 37 | self.backGroundImageView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor).isActive = true 38 | self.backGroundImageView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor).isActive = true 39 | self.backGroundImageView.topAnchor.constraint(equalTo: self.contentView.topAnchor).isActive = true 40 | self.backGroundImageView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor).isActive = true 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/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 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/UIColorExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIColorExtension.swift 3 | // PageKit 4 | // 5 | // Created by yansong li on 2017-07-16. 6 | // Copyright © 2017 yansong li. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIColor { 12 | /// Return a random color. 13 | static func randomColor() -> UIColor { 14 | let red = CGFloat(drand48()) 15 | let green = CGFloat(drand48()) 16 | let blue = CGFloat(drand48()) 17 | return UIColor(red: red, green: green, blue: blue, alpha: 1.0) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ChainPageCollectionViewDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ChainPageCollectionViewDemo 4 | // 5 | // Created by yansong li on 2017-07-23. 6 | // Copyright © 2017 yansong li. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ChainPageCollectionView 11 | 12 | class ViewController: UIViewController { 13 | 14 | let parentDataSource = ["yelp", "facebook", "netflix", "yahoo", "google", "indeed", "ritual", 15 | "sina", "new york time", "gilt"] 16 | let childImages = ["c1", "c2", "c3", "c4", "c5", "c6"] 17 | 18 | var parentIndex: Int = 0 19 | 20 | let button: UIButton = { 21 | let button = UIButton() 22 | button.setTitle("Change to Scale Animation", for: .normal) 23 | button.setTitleColor(.black, for: .normal) 24 | button.backgroundColor = UIColor(red: 237 / 255.0, 25 | green: 231 / 255.0, 26 | blue: 206 / 255.0, 27 | alpha: 1.0) 28 | return button 29 | }() 30 | 31 | let chainCollectionView = ChainPageCollectionView(viewType: .customParentHeight(28, 12)) 32 | 33 | override func viewDidLoad() { 34 | super.viewDidLoad() 35 | button.translatesAutoresizingMaskIntoConstraints = false 36 | chainCollectionView.translatesAutoresizingMaskIntoConstraints = false 37 | self.view.addSubview(button) 38 | self.view.addSubview(chainCollectionView) 39 | self.buildConstraints() 40 | button.addTarget(self, action: #selector(buttonTapped(button:)), for: .touchUpInside) 41 | chainCollectionView.parentCollectionViewItemSize = CGSize(width: 260, height: 390) 42 | // Do any additional setup after loading the view, typically from a nib. 43 | chainCollectionView.delegate = self 44 | chainCollectionView.backgroundColor = UIColor(red: 237 / 255.0, 45 | green: 231 / 255.0, 46 | blue: 206 / 255.0, 47 | alpha: 1.0) 48 | chainCollectionView.parentCollectionView.register(ImageCardCollectionViewCell.self, 49 | forCellWithReuseIdentifier: String(describing: ImageCardCollectionViewCell.self)) 50 | chainCollectionView.childCollectionView.register(ImageCardCollectionViewCell.self, 51 | forCellWithReuseIdentifier: String(describing: ImageCardCollectionViewCell.self)) 52 | self.navigationController?.navigationBar.isHidden = false 53 | self.navigationController?.navigationBar.isTranslucent = false 54 | } 55 | 56 | override var prefersStatusBarHidden: Bool { 57 | return true 58 | } 59 | } 60 | 61 | extension ViewController { 62 | func buildConstraints() { 63 | if #available(iOS 11, *) { 64 | self.button.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor).isActive = true 65 | } else { 66 | self.button.topAnchor.constraint(equalTo: self.view.topAnchor).isActive = true 67 | } 68 | self.button.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true 69 | self.button.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true 70 | self.button.bottomAnchor.constraint(equalTo: self.chainCollectionView.topAnchor).isActive = true 71 | self.chainCollectionView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true 72 | self.chainCollectionView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true 73 | if #available(iOS 11, *) { 74 | self.chainCollectionView.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor).isActive = true 75 | } else { 76 | self.chainCollectionView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true 77 | } 78 | } 79 | 80 | func buttonTapped(button: UIButton) { 81 | if chainCollectionView.childAnimationType == .slideOutSlideIn { 82 | button.setTitle("Change to Slide Animation", for: .normal) 83 | chainCollectionView.childAnimationType = .shrinkOutExpandIn 84 | } else { 85 | button.setTitle("Change to Scale Animation", for: .normal) 86 | chainCollectionView.childAnimationType = .slideOutSlideIn 87 | } 88 | } 89 | } 90 | 91 | extension ViewController: ChainPageCollectionViewProtocol { 92 | func parentCollectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 93 | return parentDataSource.count 94 | } 95 | 96 | func parentCollectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 97 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: ImageCardCollectionViewCell.self), for: indexPath) 98 | if let vCell = cell as? ImageCardCollectionViewCell { 99 | vCell.backGroundImageView.image = UIImage(named: parentDataSource[indexPath.row]) 100 | } 101 | return cell 102 | } 103 | 104 | 105 | func childCollectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 106 | return childImages.count 107 | } 108 | 109 | func childCollectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 110 | 111 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: ImageCardCollectionViewCell.self), for: indexPath) 112 | if let vCell = cell as? ImageCardCollectionViewCell { 113 | if indexPath.row == 0 { 114 | vCell.backGroundImageView.image = UIImage(named: parentDataSource[self.parentIndex]) 115 | } else { 116 | vCell.backGroundImageView.image = UIImage(named: childImages[indexPath.row]) 117 | } 118 | } 119 | return cell 120 | } 121 | 122 | func childCollectionView(_ collectionView: UICollectionView, parentCollectionViewIndex: Int) { 123 | //chainCollectionView.childCollectionViewDataReady = true 124 | // NOTE: Add a little delay to let childCollectionView/layout updates its data. 125 | DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: { 126 | self.parentIndex = parentCollectionViewIndex 127 | self.chainCollectionView.childCollectionViewDataReady = true 128 | }) 129 | } 130 | } 131 | 132 | -------------------------------------------------------------------------------- /ChainPageCollectionViewTests/ChainPageCollectionViewTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChainPageCollectionViewTests.swift 3 | // ChainPageCollectionViewTests 4 | // 5 | // Created by yansong li on 2017-07-22. 6 | // Copyright © 2017 yansong li. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import ChainPageCollectionView 11 | 12 | class ChainPageCollectionViewTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /ChainPageCollectionViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Images/ChainPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/Images/ChainPage.png -------------------------------------------------------------------------------- /Images/new1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/Images/new1.gif -------------------------------------------------------------------------------- /Images/new2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jindulys/ChainPageCollectionView/c21564c975cc6c3f98321f265f9fa767991c5067/Images/new2.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 YANSONG LI 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Metadata/ChainPageCollectionView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint ChainPageCollectionView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | s.name = "ChainPageCollectionView" 12 | s.version = "1.0.6" 13 | s.summary = "ChainPageCollectionView to animate a chain of parent-child collection view." 14 | 15 | s.homepage = "https://github.com/jindulys/ChainPageCollectionView" 16 | 17 | s.license = "MIT" 18 | 19 | s.author = { "jindulys" => "liyansong.edw@gmail.com" } 20 | 21 | s.platform = :ios, "9.0" 22 | 23 | s.source = { :git => "https://github.com/jindulys/ChainPageCollectionView.git", :tag => s.version } 24 | 25 | s.source_files = 'Sources/*.{h,swift}' 26 | 27 | # s.requires_arc = true 28 | 29 | s.pod_target_xcconfig = {'SWIFT_VERSION' => '3'} 30 | 31 | end 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # ChainPageCollectionView 6 | A custom View with two level chained collection views and fancy transition animation. 7 | 8 | ## Demo 9 | 10 | Demo Demo 11 | 12 | ## Requirements 13 | 14 | - iOS 9.0+ 15 | - Xcode 8 16 | 17 | ## Installation 18 | 19 | ### CocoaPods 20 | 21 | Update your Podfile to include the following: 22 | 23 | ```ruby 24 | pod 'ChainPageCollectionView', '~> 1.0' 25 | ``` 26 | Run `pod install`. 27 | 28 | NOTE: If you can not find the pod target. Please follow: https://stackoverflow.com/questions/31065447/no-such-module-when-i-use-cocoapods to build your pod target. 29 | 30 | ### Carthage 31 | 32 | To integrate `ChainPageCollectionView` with `Carthage`, specify it in your `Cartfile` 33 | 34 | ``` 35 | github "jindulys/ChainPageCollectionView" ~> 1.0 36 | ``` 37 | 38 | Then, run the following command to build `ChainPageCollectionView` framework 39 | 40 | ``` 41 | $ carthage update 42 | ``` 43 | At last, you need to set up your Xcode project manually to add `ChainPageCollectionView` framework. 44 | 45 | On your application targets’ `General` settings tab, in the `Linked Frameworks and Libraries` section, drag and drop each framework you want to use from the `Carthage/Build` folder on disk. 46 | 47 | On your application targets’ `Build Phases` settings tab, click the `+` icon and choose `New Run Script Phase`. Create a Run Script with the following content: 48 | 49 | ``` 50 | /usr/local/bin/carthage copy-frameworks 51 | ``` 52 | and add the paths to the frameworks you want to use under `Input Files`: 53 | 54 | ``` 55 | $(SRCROOT)/Carthage/Build/iOS/ChainPageCollectionView.framework 56 | ``` 57 | 58 | Check [Carthage](https://github.com/Carthage/Carthage) if you need more help. 59 | 60 | ## Usage 61 | 62 | ### Basic Usage 63 | 64 | ```swift 65 | import ChainPageCollectionView 66 | ``` 67 | 68 | 1. Create ChainPageCollectionView 69 | ```swift 70 | // chainView is this view controller's property. 71 | chainView = ChainPageCollectionView(viewType: .normal) 72 | chainView.delegate = self 73 | ``` 74 | 2. Register cell for `parentCollectionView` and `childCollectionView` 75 | ```swift 76 | chainView.parentCollectionView.register(#cellType, forCellWithReuseIdentifier:#cellIdentifier) 77 | chainView.childCollectionView.register(#cellType, forCellWithReuseIdentifier:#cellIdentifier) 78 | ``` 79 | 80 | 3. Implement `ChainPageCollectionViewProtocol` 81 | ```swift 82 | func parentCollectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 83 | // return your parent data source count. 84 | } 85 | 86 | func parenCollectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 87 | // Dequeue and configure your parent collectionview cell 88 | } 89 | 90 | func childCollectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 91 | // return your child data source count. 92 | } 93 | 94 | func childCollectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 95 | // Dequeue and configure your child collectionview cell 96 | } 97 | ``` 98 | 99 | 4. Update child collection view data source when parent index has changed. 100 | ```swift 101 | // You will get notified by following protocol method. 102 | func childCollectionView(_ collectionView: UICollectionView, parentCollectionViewIndex: Int) { 103 | // When parent collection view's scroll stops, this will get called with new parent collectionview's index. 104 | // You can use this message to fetch related child collection view's new data. 105 | 106 | // Once you have the latest child collection view's data, set `childCollectionViewDataReady` to `true`. 107 | // NOTE: This is important to be set, otherwise your child collection view propably will not show up again. 108 | chainView.childCollectionViewDataReady = true 109 | } 110 | ``` 111 | 112 | ### Customization 113 | 114 | #### Child Collection View Animation Type 115 | 116 | For now `ChainPageCollectionView` support two types of child collection view transition animation. 117 | 118 | ```swift 119 | public enum ChainPageChildAnimationType { 120 | case slideOutSlideIn 121 | case shrinkOutExpandIn 122 | } 123 | ``` 124 | 125 | Default is `slideOutSlideIn`, you can set it via initialization stage. 126 | ```swift 127 | let chainView = ChainPageCollectionView(viewType: .normal, 128 | childAnimationType: #yourchoice) 129 | ``` 130 | 131 | #### Layout 132 | 133 | You can customize the layout objects by passing them via `ChainPageCollectionView`'s designated initializer. 134 | ```swift 135 | let chainView = ChainPageCollectionView(viewType: .normal, 136 | parentColectionViewLayout: #yourlayout, 137 | childCollectionViewLayout: #yourlayout) 138 | ``` 139 | #### ItemSize 140 | 141 | You can use `parentCollectionViewItemSize` and `childCollectionViewItemSize` to set related layouts' itemSize. 142 | 143 | #### Screen Ratio 144 | 145 | The default behaviour of this view is that parent collection view takes `3/4` height of this view and child collection view takes the rest. You can set `viewType` to a customized ratio with type `customParentHeight(#SomeInt, #SomeInt)` 146 | ```swift 147 | let chainView = ChainPageCollectionView(viewType: .customParentHeight(28, 12)) 148 | ``` 149 | 150 | ## Author 151 | Yansong Li ( liyansong.edw@gmail.com ), wechat: `jindulys_uw` 152 | 153 | ## License 154 | 155 | Expanding collection is released under the MIT license. 156 | See [LICENSE](./LICENSE) for details. 157 | 158 | 159 | -------------------------------------------------------------------------------- /Sources/CentralCardLayout.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Yansong Li 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish, 15 | * distribute, sublicense, create a derivative work, and/or sell copies of the 16 | * Software in any work that is designed, intended, or marketed for pedagogical or 17 | * instructional purposes related to programming, coding, application development, 18 | * or information technology. Permission for such use, copying, modification, 19 | * merger, publication, distribution, sublicensing, creation of derivative works, 20 | * or sale is expressly withheld. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | 31 | import UIKit 32 | 33 | private let maxScaleOffset: CGFloat = 200 34 | private let minScale: CGFloat = 0.9 35 | private let minAlpha: CGFloat = 0.3 36 | 37 | /// The layout that can place a card at the central of the screen. 38 | public class CentralCardLayout: UICollectionViewFlowLayout { 39 | 40 | public var scaled: Bool = false 41 | 42 | fileprivate var lastCollectionViewSize: CGSize = CGSize.zero 43 | 44 | public required init?(coder aDecoder: NSCoder) { 45 | fatalError() 46 | } 47 | 48 | public init(scaled: Bool) { 49 | self.scaled = scaled 50 | super.init() 51 | scrollDirection = .horizontal 52 | minimumLineSpacing = 25 53 | } 54 | 55 | public override func invalidateLayout(with context: UICollectionViewLayoutInvalidationContext) { 56 | super.invalidateLayout(with: context) 57 | 58 | guard let collectionView = collectionView else { return } 59 | 60 | if collectionView.bounds.size != lastCollectionViewSize { 61 | configureInset() 62 | lastCollectionViewSize = collectionView.bounds.size 63 | } 64 | } 65 | 66 | public override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 67 | guard let attribute = super.layoutAttributesForItem(at: indexPath)?.copy() as? UICollectionViewLayoutAttributes else { 68 | return nil 69 | } 70 | if !scaled { 71 | return attribute 72 | } 73 | centerScaledAttribute(attribute: attribute) 74 | return attribute 75 | } 76 | 77 | public override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 78 | guard let attributes = super.layoutAttributesForElements(in: rect) else { 79 | return nil 80 | } 81 | if !scaled { 82 | return attributes 83 | } 84 | guard case let newAttributesArray as [UICollectionViewLayoutAttributes] = NSArray(array: attributes, copyItems: true) else { 85 | return nil 86 | } 87 | newAttributesArray.forEach { attribute in 88 | centerScaledAttribute(attribute: attribute) 89 | } 90 | return newAttributesArray 91 | } 92 | 93 | public override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { 94 | return true 95 | } 96 | 97 | public override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, 98 | withScrollingVelocity velocity: CGPoint) -> CGPoint { 99 | guard let collectionView = collectionView else { 100 | return proposedContentOffset 101 | } 102 | 103 | let proposedRect = CGRect(x: proposedContentOffset.x, 104 | y: 0, 105 | width: collectionView.bounds.width, 106 | height: collectionView.bounds.height) 107 | guard let layoutAttributes = layoutAttributesForElements(in: proposedRect) else { 108 | return proposedContentOffset 109 | } 110 | 111 | var shouldBeChosenAttributes: UICollectionViewLayoutAttributes? 112 | var shouldBeChosenIndex: Int = -1 113 | 114 | let proposedCenterX = proposedRect.midX 115 | 116 | for (i, attributes) in layoutAttributes.enumerated() { 117 | guard attributes .representedElementCategory == .cell else { 118 | continue 119 | } 120 | guard let currentChosenAttributes = shouldBeChosenAttributes else { 121 | shouldBeChosenAttributes = attributes 122 | shouldBeChosenIndex = i 123 | continue 124 | } 125 | if (fabs(attributes.frame.midX - proposedCenterX) < fabs(currentChosenAttributes.frame.midX - proposedCenterX)) { 126 | shouldBeChosenAttributes = attributes 127 | shouldBeChosenIndex = i 128 | } 129 | } 130 | // Adjust the case where a quick but small scroll occurs. 131 | if (fabs(collectionView.contentOffset.x - proposedContentOffset.x) < itemSize.width) { 132 | if velocity.x < -0.3 { 133 | shouldBeChosenIndex = shouldBeChosenIndex > 0 ? shouldBeChosenIndex - 1 : shouldBeChosenIndex 134 | } else if velocity.x > 0.3 { 135 | shouldBeChosenIndex = shouldBeChosenIndex < layoutAttributes.count - 1 ? 136 | shouldBeChosenIndex + 1 : shouldBeChosenIndex 137 | } 138 | shouldBeChosenAttributes = layoutAttributes[shouldBeChosenIndex] 139 | } 140 | guard let finalAttributes = shouldBeChosenAttributes else { 141 | return proposedContentOffset 142 | } 143 | return CGPoint(x: finalAttributes.frame.midX - collectionView.bounds.size.width / 2, 144 | y: proposedContentOffset.y) 145 | } 146 | } 147 | 148 | // MARK: helpers 149 | 150 | extension CentralCardLayout { 151 | fileprivate func centerScaledAttribute(attribute: UICollectionViewLayoutAttributes) { 152 | guard let collectionView = collectionView else { 153 | return 154 | } 155 | let visibleRect = CGRect(x: collectionView.contentOffset.x, 156 | y: collectionView.contentOffset.y, 157 | width: collectionView.bounds.size.width, 158 | height: collectionView.bounds.size.height) 159 | let visibleCenterX = visibleRect.midX 160 | let distanceFromCenter = visibleCenterX - attribute.center.x 161 | let distance = min(abs(distanceFromCenter), maxScaleOffset) 162 | let scale = distance * (minScale - 1) / maxScaleOffset + 1 163 | attribute.transform3D = CATransform3DScale(CATransform3DIdentity, scale, scale, 1) 164 | attribute.alpha = distance * (minAlpha - 1) / maxScaleOffset + 1 165 | } 166 | 167 | fileprivate func configureInset() -> Void { 168 | guard let collectionView = collectionView else { 169 | return 170 | } 171 | let inset = collectionView.bounds.size.width / 2 - itemSize.width / 2 172 | collectionView.contentInset = UIEdgeInsetsMake(0, inset, 0, inset) 173 | collectionView.contentOffset = CGPoint(x: -inset, y: 0) 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /Sources/ChainCollectionViewProtocol.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Yansong Li 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish, 15 | * distribute, sublicense, create a derivative work, and/or sell copies of the 16 | * Software in any work that is designed, intended, or marketed for pedagogical or 17 | * instructional purposes related to programming, coding, application development, 18 | * or information technology. Permission for such use, copying, modification, 19 | * merger, publication, distribution, sublicensing, creation of derivative works, 20 | * or sale is expressly withheld. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | 31 | import UIKit 32 | 33 | /// The protocol of ChainPageCollectionView. 34 | @objc public protocol ChainPageCollectionViewProtocol: UICollectionViewDelegate { 35 | 36 | func parentCollectionView(_ collectionView: UICollectionView, 37 | numberOfItemsInSection section: Int) -> Int 38 | 39 | func parentCollectionView(_ collectionView: UICollectionView, 40 | cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 41 | 42 | @objc optional func parentCollectionView(_ collectionView: UICollectionView, 43 | willDisplay cell: UICollectionViewCell, 44 | forItemAt indexPath: IndexPath) 45 | 46 | @objc optional func parentCollectionView(_ collectionView: UICollectionView, 47 | canMoveItemAt indexPath: IndexPath) -> Bool 48 | 49 | @objc optional func parentCollectionView(_ collectionView: UICollectionView, 50 | moveItemAt sourceIndexPath: IndexPath, 51 | to destinationIndexPath: IndexPath) 52 | 53 | @objc optional func parentCollectionView(_ collectionView: UICollectionView, 54 | didSelectItemAt indexPath: IndexPath) 55 | 56 | func childCollectionView(_ collectionView: UICollectionView, 57 | numberOfItemsInSection section: Int) -> Int 58 | 59 | func childCollectionView(_ collectionView: UICollectionView, 60 | cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 61 | 62 | @objc optional func childCollectionView(_ collectionView: UICollectionView, 63 | didSelectItemAt indexPath: IndexPath) 64 | 65 | @objc optional func childCollectionView(_ collectionView: UICollectionView, 66 | willDisplay cell: UICollectionViewCell, 67 | forItemAt indexPath: IndexPath) 68 | 69 | @objc optional func childCollectionView(_ collectionView: UICollectionView, 70 | canMoveItemAt indexPath: IndexPath) -> Bool 71 | 72 | @objc optional func childCollectionView(_ collectionView: UICollectionView, 73 | moveItemAt sourceIndexPath: IndexPath, 74 | to destinationIndexPath: IndexPath) 75 | 76 | /// Let childCollectionView reload data with current parent collection view index. 77 | func childCollectionView(_ collectionView: UICollectionView, parentCollectionViewIndex: Int) 78 | } 79 | -------------------------------------------------------------------------------- /Sources/ChainPageCollectionView.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChainPageCollectionView.h 3 | // ChainPageCollectionView 4 | // 5 | // Created by yansong li on 2017-07-22. 6 | // Copyright © 2017 yansong li. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for ChainPageCollectionView. 12 | FOUNDATION_EXPORT double ChainPageCollectionViewVersionNumber; 13 | 14 | //! Project version string for ChainPageCollectionView. 15 | FOUNDATION_EXPORT const unsigned char ChainPageCollectionViewVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Sources/ChainPageCollectionView.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Yansong Li 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish, 15 | * distribute, sublicense, create a derivative work, and/or sell copies of the 16 | * Software in any work that is designed, intended, or marketed for pedagogical or 17 | * instructional purposes related to programming, coding, application development, 18 | * or information technology. Permission for such use, copying, modification, 19 | * merger, publication, distribution, sublicensing, creation of derivative works, 20 | * or sale is expressly withheld. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | 31 | import UIKit 32 | 33 | private let defaultParentChildRatio: CGFloat = 3 / 4 34 | private var defaultParentCellVerticalPadding: CGFloat = 50 35 | private var defaultParentCellWidthHeightRatio: CGFloat = 3 / 4 36 | private var defaultChildCellVerticalPadding: CGFloat = 12 37 | private var defaultChildCellWidthHeightRatio: CGFloat = 3 / 4 38 | private let defaultFadeOutDuration: TimeInterval = 0.2 39 | private let defaultFadeInDuration: TimeInterval = 0.2 40 | 41 | public enum ChainPageCollectionViewType { 42 | 43 | /// normal type splits the height to 3 : 1 44 | case normal 45 | 46 | /// customParentHeight type will splits the screen to custom ratio. 47 | case customParentHeight(Int, Int) 48 | 49 | func viewHeightRatio() -> CGFloat { 50 | switch self { 51 | case .normal: 52 | return defaultParentChildRatio 53 | case let .customParentHeight(pInt, cInt): 54 | guard pInt > 0, cInt > 0 else { 55 | return defaultParentChildRatio 56 | } 57 | let total = CGFloat(pInt + cInt) 58 | return CGFloat(pInt) / total 59 | } 60 | } 61 | } 62 | 63 | public enum ChainPageChildAnimationType { 64 | case slideOutSlideIn 65 | case shrinkOutExpandIn 66 | } 67 | 68 | fileprivate enum ChildAnimationState { 69 | case initial 70 | case fadeOutChild 71 | case fadeOutComplete 72 | case fadeInChild 73 | indirect case toProcess(ChildAnimationState, ChildAnimationState) 74 | } 75 | 76 | /// The view which contains chained collectionViews. 77 | /// The change of parent view can reload its child collectionView. 78 | open class ChainPageCollectionView: UIView { 79 | 80 | /// The parent collection view. 81 | public var parentCollectionView: UICollectionView! 82 | 83 | /// The child collection view. 84 | public var childCollectionView: UICollectionView! 85 | 86 | public var parentCollectionViewItemSize: CGSize = .zero 87 | 88 | public var childCollectionViewItemSize: CGSize = .zero 89 | 90 | public var childAnimationType: ChainPageChildAnimationType 91 | 92 | public weak var delegate: ChainPageCollectionViewProtocol? 93 | 94 | fileprivate var parentIndexChangeDuringFadeIn: Bool = false 95 | 96 | fileprivate var preprocessBeforeChildCollectionViewReload: (()->())? 97 | 98 | fileprivate var lastTimeViewHeight: CGFloat = 0.0 99 | 100 | fileprivate let viewType: ChainPageCollectionViewType 101 | 102 | fileprivate var state: ChildAnimationState = .initial 103 | 104 | /// The selection index of parentCollectionView. 105 | public var parentCollectionViewIndex: Int = 0 { 106 | didSet { 107 | if parentCollectionViewIndex == oldValue { 108 | return 109 | } 110 | delegate?.childCollectionView(childCollectionView, 111 | parentCollectionViewIndex: parentCollectionViewIndex) 112 | self <= .fadeOutChild 113 | } 114 | } 115 | 116 | public var childCollectionViewDataReady: Bool = false { 117 | didSet { 118 | // NOTE: Whenever user of this view sets this field to `true`, it means new data has come 119 | // we need to update UI according to current state. 120 | if childCollectionViewDataReady { 121 | switch self.state { 122 | case .initial: 123 | self <= .fadeOutChild 124 | case .fadeInChild: 125 | self <= .fadeOutChild 126 | case .fadeOutComplete: 127 | self <= .fadeInChild 128 | default: 129 | break 130 | } 131 | } 132 | } 133 | } 134 | 135 | public init(viewType: ChainPageCollectionViewType, 136 | parentCollectionViewLayout: UICollectionViewFlowLayout = CentralCardLayout(scaled: true), 137 | childCollectionViewLayout: UICollectionViewFlowLayout = EdgeCardLayout(), 138 | childAnimationType: ChainPageChildAnimationType = .slideOutSlideIn) { 139 | self.viewType = viewType 140 | self.childAnimationType = childAnimationType 141 | 142 | parentCollectionView = 143 | UICollectionView(frame: .zero, 144 | collectionViewLayout: parentCollectionViewLayout) 145 | parentCollectionView.backgroundColor = .clear 146 | parentCollectionView.decelerationRate = UIScrollViewDecelerationRateFast 147 | 148 | let childCollectionViewLayout = childCollectionViewLayout 149 | childCollectionViewLayout.scrollDirection = .horizontal 150 | childCollectionViewLayout.minimumLineSpacing = 16 151 | childCollectionView = UICollectionView(frame: .zero, 152 | collectionViewLayout: childCollectionViewLayout) 153 | childCollectionView.decelerationRate = UIScrollViewDecelerationRateFast 154 | childCollectionView.backgroundColor = .clear 155 | 156 | super.init(frame: .zero) 157 | parentCollectionView.translatesAutoresizingMaskIntoConstraints = false 158 | childCollectionView.translatesAutoresizingMaskIntoConstraints = false 159 | addSubview(parentCollectionView) 160 | addSubview(childCollectionView) 161 | parentCollectionView.dataSource = self 162 | parentCollectionView.delegate = self 163 | childCollectionView.dataSource = self 164 | childCollectionView.delegate = self 165 | buildConstraints() 166 | } 167 | 168 | required public init?(coder aDecoder: NSCoder) { 169 | fatalError("init(coder:) has not been implemented") 170 | } 171 | 172 | open override func layoutSubviews() { 173 | super.layoutSubviews() 174 | let viewHeight = bounds.size.height 175 | if viewHeight != lastTimeViewHeight { 176 | lastTimeViewHeight = bounds.size.height 177 | let parentHeightRatio = viewType.viewHeightRatio() 178 | 179 | // Adjust parentCollectionViewItemSize. 180 | var validParentItemSize: CGSize = .zero 181 | if (parentCollectionViewItemSize == .zero || 182 | parentCollectionViewItemSize.height > viewHeight * parentHeightRatio) { 183 | let parentItemHeight = viewHeight * parentHeightRatio - 2 * defaultParentCellVerticalPadding 184 | validParentItemSize = 185 | CGSize(width: parentItemHeight * defaultParentCellWidthHeightRatio, 186 | height: parentItemHeight) 187 | } else { 188 | // Restore user's setting. e.g: Rotate to horizontal then rotate back. 189 | validParentItemSize = parentCollectionViewItemSize 190 | } 191 | if let parentLayout = parentCollectionView.collectionViewLayout as? CentralCardLayout { 192 | parentLayout.itemSize = validParentItemSize 193 | } 194 | 195 | // Adjust childCollectionViewItemSize. 196 | var validChildItemSize: CGSize = .zero 197 | if childCollectionViewItemSize == .zero || 198 | childCollectionViewItemSize.height > viewHeight * (1 - parentHeightRatio) { 199 | let childItemHeight = 200 | viewHeight * (1 - parentHeightRatio) - 2 * defaultChildCellVerticalPadding 201 | validChildItemSize = CGSize(width: childItemHeight * defaultChildCellWidthHeightRatio, 202 | height: childItemHeight) 203 | } else { 204 | validChildItemSize = childCollectionViewItemSize 205 | } 206 | if let childLayout = childCollectionView.collectionViewLayout as? UICollectionViewFlowLayout { 207 | childLayout.itemSize = validChildItemSize 208 | } 209 | } 210 | } 211 | } 212 | 213 | // MARK: - Helpers 214 | 215 | extension ChainPageCollectionView { 216 | fileprivate static func <=(left: ChainPageCollectionView, right: ChildAnimationState) { 217 | switch (left.state, right) { 218 | 219 | case (.initial, .fadeOutChild): 220 | left.state = .fadeOutChild 221 | left.childCollectionView.isUserInteractionEnabled = false 222 | left.childCollectionViewFadeOut() 223 | 224 | case (.fadeOutChild, .fadeOutComplete): 225 | left.state = .fadeOutComplete 226 | 227 | case (.fadeOutComplete, .fadeInChild): 228 | if left.childCollectionViewDataReady { 229 | left.state = .fadeInChild 230 | left.childCollectionViewReload() 231 | } 232 | 233 | case (.fadeInChild, .fadeOutChild): 234 | left.state = .toProcess(.fadeInChild, .fadeOutChild) 235 | left.parentIndexChangeDuringFadeIn = true 236 | 237 | case let(.toProcess(originalState, nextState), .initial): 238 | left.state = originalState 239 | left <= .initial 240 | left <= nextState 241 | 242 | case (.fadeInChild, .initial): 243 | left.state = .initial 244 | left.childCollectionView.isUserInteractionEnabled = true 245 | if left.parentIndexChangeDuringFadeIn { 246 | left.parentIndexChangeDuringFadeIn = false 247 | } else { 248 | left.childCollectionViewDataReady = false 249 | } 250 | left.preprocessBeforeChildCollectionViewReload = nil 251 | 252 | default: 253 | break 254 | } 255 | } 256 | 257 | func childCollectionViewFadeOut() { 258 | /// Animate out currently child collection view cells. 259 | addChildCollectionViewFadeOutAnimation() { finish in 260 | self <= .fadeOutComplete 261 | self <= .fadeInChild 262 | } 263 | } 264 | 265 | public func childCollectionViewReload() { 266 | preprocessBeforeChildCollectionViewReload?() 267 | self.childCollectionView.reloadData() 268 | if let childCollectionViewLayout = 269 | self.childCollectionView.collectionViewLayout as? UICollectionViewFlowLayout { 270 | self.childCollectionView.contentOffset = 271 | CGPoint(x: -childCollectionViewLayout.minimumLineSpacing, y: 0) 272 | } 273 | // NOTE: Add a little delay to let childCollectionView/layout updates its data. 274 | DispatchQueue.main.async{ 275 | self.addChildCollectionViewFadeInAnimation() { finish in 276 | self <= .initial 277 | } 278 | } 279 | } 280 | 281 | func addChildCollectionViewFadeOutAnimation(completionBlock: ((Bool)->())? = nil) { 282 | let indexPaths = childCollectionView.indexPathsForVisibleItems.sorted { $0.row < $1.row } 283 | var restoreCellBlocks: [() -> ()] = [] 284 | 285 | CATransaction.begin() 286 | CATransaction.setCompletionBlock { 287 | // NOTE: Since we are always using childCollectionView and we changed 288 | // cell's metrics manually, we should restore cell metrics to avoid 289 | // incorrect cell state when dequeued. 290 | self.preprocessBeforeChildCollectionViewReload = { 291 | restoreCellBlocks.forEach { $0() } 292 | } 293 | completionBlock?(true) 294 | } 295 | for (i, index) in indexPaths.enumerated() { 296 | if let cell = self.childCollectionView.cellForItem(at: index) { 297 | var animationBlock: ()->() = {} 298 | var restoreBlock: ()->() = {} 299 | switch self.childAnimationType { 300 | case .slideOutSlideIn: 301 | let originalFrame = cell.frame 302 | animationBlock = { 303 | var newFrame = cell.frame 304 | newFrame.origin.y = 305 | self.childCollectionView.frame.size.height 306 | cell.frame = newFrame 307 | cell.alpha = 0.0 308 | } 309 | restoreBlock = { 310 | cell.frame = originalFrame 311 | cell.alpha = 1.0 312 | } 313 | case .shrinkOutExpandIn: 314 | animationBlock = { 315 | cell.transform = CGAffineTransform(scaleX: 0.3, y: 0.3) 316 | cell.alpha = 0.0 317 | } 318 | restoreBlock = { 319 | cell.transform = .identity 320 | cell.alpha = 1.0 321 | } 322 | } 323 | restoreCellBlocks.append(restoreBlock) 324 | UIView.animate(withDuration: defaultFadeOutDuration, 325 | delay: Double(i)*0.1, 326 | options: [], 327 | animations: animationBlock, 328 | completion: nil) 329 | } 330 | } 331 | CATransaction.commit() 332 | } 333 | 334 | func addChildCollectionViewFadeInAnimation(completionBlock: ((Bool)->())? = nil) { 335 | let indexPaths = self.childCollectionViewFadeInCellIndexes() 336 | CATransaction.begin() 337 | CATransaction.setCompletionBlock { 338 | completionBlock?(true) 339 | } 340 | for (i, indexPath) in indexPaths.enumerated() { 341 | if let cell = self.childCollectionView.cellForItem(at: indexPath) { 342 | var animationBlock: ()->() = {} 343 | switch self.childAnimationType { 344 | case .slideOutSlideIn: 345 | var newFrame = cell.frame 346 | newFrame.origin.y = self.childCollectionView.frame.size.height 347 | cell.frame = newFrame 348 | animationBlock = { 349 | newFrame.origin.y = defaultChildCellVerticalPadding 350 | cell.frame = newFrame 351 | cell.alpha = 1.0 352 | } 353 | case .shrinkOutExpandIn: 354 | cell.transform = CGAffineTransform(scaleX: 0.3, y: 0.3) 355 | animationBlock = { 356 | cell.transform = .identity 357 | cell.alpha = 1.0 358 | } 359 | } 360 | UIView.animate(withDuration: defaultFadeInDuration, 361 | delay: Double(i)*0.17, 362 | options: [], 363 | animations: animationBlock, 364 | completion: nil) 365 | } 366 | } 367 | CATransaction.commit() 368 | } 369 | } 370 | 371 | extension ChainPageCollectionView { 372 | func buildConstraints() { 373 | parentCollectionView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true 374 | parentCollectionView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true 375 | parentCollectionView.topAnchor.constraint(equalTo: topAnchor).isActive = true 376 | parentCollectionView.heightAnchor.constraint(equalTo: heightAnchor, 377 | multiplier: viewType.viewHeightRatio()).isActive = true 378 | childCollectionView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true 379 | childCollectionView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true 380 | childCollectionView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true 381 | childCollectionView.topAnchor.constraint(equalTo: parentCollectionView.bottomAnchor).isActive = true 382 | } 383 | 384 | func childCollectionViewFadeInCellIndexes() -> [IndexPath] { 385 | guard let layout = childCollectionView.collectionViewLayout as? UICollectionViewFlowLayout else { 386 | return [] 387 | } 388 | let visibleCellsCount = 389 | Int(ceil((childCollectionView.frame.size.width - childCollectionView.contentInset.left) / 390 | (layout.itemSize.width + layout.minimumLineSpacing))) 391 | 392 | var indexPaths: [IndexPath] = [] 393 | for i in 0.. Int { 407 | guard let validDelegate = delegate else { 408 | assert(false, "Need delegate!") 409 | return 0 410 | } 411 | if collectionView == parentCollectionView { 412 | return validDelegate.parentCollectionView(parentCollectionView, numberOfItemsInSection: section) 413 | } else { 414 | return validDelegate.childCollectionView(childCollectionView, numberOfItemsInSection: section) 415 | } 416 | } 417 | 418 | public func numberOfSections(in collectionView: UICollectionView) -> Int { 419 | // NOT support multiple sections. 420 | return 1 421 | } 422 | 423 | public func collectionView(_ collectionView: UICollectionView, 424 | cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 425 | guard let validDelegate = delegate else { 426 | assert(false, "Need delegate!") 427 | return UICollectionViewCell() 428 | } 429 | if collectionView == parentCollectionView { 430 | return validDelegate.parentCollectionView(parentCollectionView, cellForItemAt: indexPath) 431 | } else { 432 | return validDelegate.childCollectionView(childCollectionView, cellForItemAt: indexPath) 433 | } 434 | } 435 | 436 | public func collectionView(_ collectionView: UICollectionView, 437 | canMoveItemAt indexPath: IndexPath)-> Bool { 438 | guard let validDelegate = delegate else { 439 | assert(false, "Need delegate!") 440 | return true 441 | } 442 | if collectionView == parentCollectionView, 443 | let result = validDelegate.parentCollectionView?(parentCollectionView, 444 | canMoveItemAt: indexPath) { 445 | return result 446 | } else if collectionView == childCollectionView, 447 | let result = validDelegate.childCollectionView?(childCollectionView, 448 | canMoveItemAt: indexPath) { 449 | return result 450 | } 451 | return true 452 | } 453 | 454 | public func collectionView(_ collectionView: UICollectionView, 455 | moveItemAt sourceIndexPath: IndexPath, 456 | to destinationIndexPath: IndexPath) { 457 | guard let validDelegate = delegate else { 458 | assert(false, "Need delegate!") 459 | return 460 | } 461 | if collectionView == parentCollectionView { 462 | validDelegate.parentCollectionView?(parentCollectionView, 463 | moveItemAt: sourceIndexPath, 464 | to: destinationIndexPath) 465 | } else if collectionView == childCollectionView { 466 | validDelegate.parentCollectionView?(parentCollectionView, 467 | moveItemAt: sourceIndexPath, 468 | to: destinationIndexPath) 469 | } 470 | } 471 | 472 | public func collectionView(_ collectionView: UICollectionView, 473 | willDisplay cell: UICollectionViewCell, 474 | forItemAt indexPath: IndexPath) { 475 | guard let validDelegate = delegate else { 476 | assert(false, "Need delegate!") 477 | return 478 | } 479 | if collectionView == parentCollectionView { 480 | print("Will display cell:\(cell)") 481 | validDelegate.parentCollectionView?(parentCollectionView, willDisplay: cell, 482 | forItemAt: indexPath) 483 | } else { 484 | let animatedIndexPaths = childCollectionViewFadeInCellIndexes() 485 | // NOTE: During animation, only change those animated cell's alpha to 0.0 486 | switch self.state { 487 | case .fadeInChild: 488 | if animatedIndexPaths.contains(indexPath) { 489 | cell.alpha = 0.0 490 | } 491 | default: 492 | break 493 | } 494 | validDelegate.childCollectionView?(childCollectionView, willDisplay: cell, 495 | forItemAt: indexPath) 496 | } 497 | } 498 | 499 | public func collectionView(_ collectionView: UICollectionView, 500 | didSelectItemAt indexPath: IndexPath) { 501 | guard let validDelegate = delegate else { 502 | assert(false, "Need delegate!") 503 | return 504 | } 505 | if collectionView == parentCollectionView { 506 | validDelegate.parentCollectionView?(parentCollectionView, didSelectItemAt: indexPath) 507 | } else if collectionView == childCollectionView { 508 | validDelegate.childCollectionView?(childCollectionView, didSelectItemAt: indexPath) 509 | } 510 | } 511 | 512 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 513 | guard let collectionView = scrollView as? UICollectionView, 514 | collectionView == parentCollectionView, 515 | let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout else { 516 | return 517 | } 518 | let initialOffset = (collectionView.bounds.size.width - layout.itemSize.width) / 2 519 | let currentItemCentralX = 520 | collectionView.contentOffset.x + initialOffset + layout.itemSize.width / 2 521 | let pageWidth = layout.itemSize.width + layout.minimumLineSpacing 522 | parentCollectionViewIndex = Int(currentItemCentralX / pageWidth) 523 | } 524 | } 525 | -------------------------------------------------------------------------------- /Sources/EdgeCardLayout.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Yansong Li 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish, 15 | * distribute, sublicense, create a derivative work, and/or sell copies of the 16 | * Software in any work that is designed, intended, or marketed for pedagogical or 17 | * instructional purposes related to programming, coding, application development, 18 | * or information technology. Permission for such use, copying, modification, 19 | * merger, publication, distribution, sublicensing, creation of derivative works, 20 | * or sale is expressly withheld. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | 31 | import UIKit 32 | 33 | /// The layout that can place a card at the left edge of screen. 34 | public class EdgeCardLayout: UICollectionViewFlowLayout { 35 | 36 | fileprivate var lastCollectionViewSize: CGSize = CGSize.zero 37 | 38 | public required init?(coder aDecoder: NSCoder) { 39 | fatalError() 40 | } 41 | 42 | override init() { 43 | super.init() 44 | scrollDirection = .horizontal 45 | minimumLineSpacing = 25 46 | } 47 | 48 | public override func invalidateLayout(with context: UICollectionViewLayoutInvalidationContext) { 49 | super.invalidateLayout(with: context) 50 | 51 | guard let collectionView = collectionView else { return } 52 | 53 | if collectionView.bounds.size != lastCollectionViewSize { 54 | configureInset() 55 | lastCollectionViewSize = collectionView.bounds.size 56 | } 57 | } 58 | 59 | public override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, 60 | withScrollingVelocity velocity: CGPoint) -> CGPoint { 61 | guard let collectionView = collectionView else { 62 | return proposedContentOffset 63 | } 64 | 65 | let proposedRect = CGRect(x: proposedContentOffset.x, 66 | y: 0, 67 | width: collectionView.bounds.width, 68 | height: collectionView.bounds.height) 69 | guard var layoutAttributes = layoutAttributesForElements(in: proposedRect) else { 70 | return proposedContentOffset 71 | } 72 | 73 | layoutAttributes = layoutAttributes.sorted { $0.frame.origin.x < $1.frame.origin.x } 74 | let leftMostAttribute = layoutAttributes[0] 75 | 76 | if leftMostAttribute.frame.origin.x > proposedContentOffset.x { 77 | return CGPoint(x: leftMostAttribute.frame.origin.x - minimumLineSpacing, 78 | y: proposedContentOffset.y) 79 | } 80 | 81 | if velocity.x > 0 { 82 | if fabs(leftMostAttribute.frame.origin.x - proposedContentOffset.x) > (itemSize.width / 2) 83 | || velocity.x > 0.3 { 84 | return CGPoint(x: leftMostAttribute.frame.maxX, y: proposedContentOffset.y) 85 | } else { 86 | return CGPoint(x: leftMostAttribute.frame.origin.x - minimumLineSpacing, 87 | y: proposedContentOffset.y) 88 | } 89 | } 90 | if velocity.x < 0 { 91 | if fabs(leftMostAttribute.frame.origin.x - proposedContentOffset.x) <= (itemSize.width / 2) 92 | || velocity.x < -0.3 { 93 | return CGPoint(x: leftMostAttribute.frame.origin.x - minimumLineSpacing, 94 | y: proposedContentOffset.y) 95 | } else { 96 | return CGPoint(x: leftMostAttribute.frame.maxX, y: proposedContentOffset.y) 97 | } 98 | } 99 | 100 | return proposedContentOffset 101 | } 102 | } 103 | 104 | // MARK: helpers 105 | 106 | extension EdgeCardLayout { 107 | 108 | fileprivate func configureInset() -> Void { 109 | guard let collectionView = collectionView else { 110 | return 111 | } 112 | let inset = minimumLineSpacing 113 | collectionView.contentInset = UIEdgeInsetsMake(0, inset, 0, inset) 114 | collectionView.contentOffset = CGPoint(x: -inset, y: 0) 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /Sources/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | --------------------------------------------------------------------------------