├── .gitignore ├── CollectionViewPeekingPages.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── CollectionViewPeekingPages ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── HorizontalPeekingPagesCollectionViewController.swift ├── Info.plist ├── MyCollectionViewController.swift └── ViewController.swift ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 986F17202078094500FC39A5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F171F2078094500FC39A5 /* AppDelegate.swift */; }; 11 | 986F17222078094500FC39A5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F17212078094500FC39A5 /* ViewController.swift */; }; 12 | 986F17252078094500FC39A5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 986F17232078094500FC39A5 /* Main.storyboard */; }; 13 | 986F17272078094700FC39A5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 986F17262078094700FC39A5 /* Assets.xcassets */; }; 14 | 986F172A2078094700FC39A5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 986F17282078094700FC39A5 /* LaunchScreen.storyboard */; }; 15 | 986F174E207809F700FC39A5 /* HorizontalPeekingPagesCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F174D207809F700FC39A5 /* HorizontalPeekingPagesCollectionViewController.swift */; }; 16 | 986F175020780DFD00FC39A5 /* MyCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 986F174F20780DFD00FC39A5 /* MyCollectionViewController.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 986F17312078094700FC39A5 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 986F17142078094500FC39A5 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 986F171B2078094500FC39A5; 25 | remoteInfo = CollectionViewPeekingPages; 26 | }; 27 | 986F173C2078094700FC39A5 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = 986F17142078094500FC39A5 /* Project object */; 30 | proxyType = 1; 31 | remoteGlobalIDString = 986F171B2078094500FC39A5; 32 | remoteInfo = CollectionViewPeekingPages; 33 | }; 34 | /* End PBXContainerItemProxy section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | 986F171C2078094500FC39A5 /* CollectionViewPeekingPages.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionViewPeekingPages.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 986F171F2078094500FC39A5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 39 | 986F17212078094500FC39A5 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 40 | 986F17242078094500FC39A5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | 986F17262078094700FC39A5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 42 | 986F17292078094700FC39A5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 43 | 986F172B2078094700FC39A5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 986F17302078094700FC39A5 /* CollectionViewPeekingPagesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CollectionViewPeekingPagesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 986F173B2078094700FC39A5 /* CollectionViewPeekingPagesUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CollectionViewPeekingPagesUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 986F174D207809F700FC39A5 /* HorizontalPeekingPagesCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HorizontalPeekingPagesCollectionViewController.swift; sourceTree = ""; }; 47 | 986F174F20780DFD00FC39A5 /* MyCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCollectionViewController.swift; sourceTree = ""; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | 986F17192078094500FC39A5 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | 986F172D2078094700FC39A5 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | 986F17382078094700FC39A5 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | 986F17132078094500FC39A5 = { 76 | isa = PBXGroup; 77 | children = ( 78 | 986F171E2078094500FC39A5 /* CollectionViewPeekingPages */, 79 | 986F171D2078094500FC39A5 /* Products */, 80 | ); 81 | sourceTree = ""; 82 | }; 83 | 986F171D2078094500FC39A5 /* Products */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 986F171C2078094500FC39A5 /* CollectionViewPeekingPages.app */, 87 | 986F17302078094700FC39A5 /* CollectionViewPeekingPagesTests.xctest */, 88 | 986F173B2078094700FC39A5 /* CollectionViewPeekingPagesUITests.xctest */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | 986F171E2078094500FC39A5 /* CollectionViewPeekingPages */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 986F171F2078094500FC39A5 /* AppDelegate.swift */, 97 | 986F17212078094500FC39A5 /* ViewController.swift */, 98 | 986F174F20780DFD00FC39A5 /* MyCollectionViewController.swift */, 99 | 986F17232078094500FC39A5 /* Main.storyboard */, 100 | 986F174D207809F700FC39A5 /* HorizontalPeekingPagesCollectionViewController.swift */, 101 | 986F17262078094700FC39A5 /* Assets.xcassets */, 102 | 986F17282078094700FC39A5 /* LaunchScreen.storyboard */, 103 | 986F172B2078094700FC39A5 /* Info.plist */, 104 | ); 105 | path = CollectionViewPeekingPages; 106 | sourceTree = ""; 107 | }; 108 | /* End PBXGroup section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | 986F171B2078094500FC39A5 /* CollectionViewPeekingPages */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = 986F17442078094700FC39A5 /* Build configuration list for PBXNativeTarget "CollectionViewPeekingPages" */; 114 | buildPhases = ( 115 | 986F17182078094500FC39A5 /* Sources */, 116 | 986F17192078094500FC39A5 /* Frameworks */, 117 | 986F171A2078094500FC39A5 /* Resources */, 118 | ); 119 | buildRules = ( 120 | ); 121 | dependencies = ( 122 | ); 123 | name = CollectionViewPeekingPages; 124 | productName = CollectionViewPeekingPages; 125 | productReference = 986F171C2078094500FC39A5 /* CollectionViewPeekingPages.app */; 126 | productType = "com.apple.product-type.application"; 127 | }; 128 | 986F172F2078094700FC39A5 /* CollectionViewPeekingPagesTests */ = { 129 | isa = PBXNativeTarget; 130 | buildConfigurationList = 986F17472078094700FC39A5 /* Build configuration list for PBXNativeTarget "CollectionViewPeekingPagesTests" */; 131 | buildPhases = ( 132 | 986F172C2078094700FC39A5 /* Sources */, 133 | 986F172D2078094700FC39A5 /* Frameworks */, 134 | 986F172E2078094700FC39A5 /* Resources */, 135 | ); 136 | buildRules = ( 137 | ); 138 | dependencies = ( 139 | 986F17322078094700FC39A5 /* PBXTargetDependency */, 140 | ); 141 | name = CollectionViewPeekingPagesTests; 142 | productName = CollectionViewPeekingPagesTests; 143 | productReference = 986F17302078094700FC39A5 /* CollectionViewPeekingPagesTests.xctest */; 144 | productType = "com.apple.product-type.bundle.unit-test"; 145 | }; 146 | 986F173A2078094700FC39A5 /* CollectionViewPeekingPagesUITests */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = 986F174A2078094700FC39A5 /* Build configuration list for PBXNativeTarget "CollectionViewPeekingPagesUITests" */; 149 | buildPhases = ( 150 | 986F17372078094700FC39A5 /* Sources */, 151 | 986F17382078094700FC39A5 /* Frameworks */, 152 | 986F17392078094700FC39A5 /* Resources */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | 986F173D2078094700FC39A5 /* PBXTargetDependency */, 158 | ); 159 | name = CollectionViewPeekingPagesUITests; 160 | productName = CollectionViewPeekingPagesUITests; 161 | productReference = 986F173B2078094700FC39A5 /* CollectionViewPeekingPagesUITests.xctest */; 162 | productType = "com.apple.product-type.bundle.ui-testing"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | 986F17142078094500FC39A5 /* Project object */ = { 168 | isa = PBXProject; 169 | attributes = { 170 | LastSwiftUpdateCheck = 0930; 171 | LastUpgradeCheck = 0930; 172 | ORGANIZATIONNAME = "Shai Balassiano"; 173 | TargetAttributes = { 174 | 986F171B2078094500FC39A5 = { 175 | CreatedOnToolsVersion = 9.3; 176 | }; 177 | 986F172F2078094700FC39A5 = { 178 | CreatedOnToolsVersion = 9.3; 179 | TestTargetID = 986F171B2078094500FC39A5; 180 | }; 181 | 986F173A2078094700FC39A5 = { 182 | CreatedOnToolsVersion = 9.3; 183 | TestTargetID = 986F171B2078094500FC39A5; 184 | }; 185 | }; 186 | }; 187 | buildConfigurationList = 986F17172078094500FC39A5 /* Build configuration list for PBXProject "CollectionViewPeekingPages" */; 188 | compatibilityVersion = "Xcode 9.3"; 189 | developmentRegion = en; 190 | hasScannedForEncodings = 0; 191 | knownRegions = ( 192 | en, 193 | Base, 194 | ); 195 | mainGroup = 986F17132078094500FC39A5; 196 | productRefGroup = 986F171D2078094500FC39A5 /* Products */; 197 | projectDirPath = ""; 198 | projectRoot = ""; 199 | targets = ( 200 | 986F171B2078094500FC39A5 /* CollectionViewPeekingPages */, 201 | 986F172F2078094700FC39A5 /* CollectionViewPeekingPagesTests */, 202 | 986F173A2078094700FC39A5 /* CollectionViewPeekingPagesUITests */, 203 | ); 204 | }; 205 | /* End PBXProject section */ 206 | 207 | /* Begin PBXResourcesBuildPhase section */ 208 | 986F171A2078094500FC39A5 /* Resources */ = { 209 | isa = PBXResourcesBuildPhase; 210 | buildActionMask = 2147483647; 211 | files = ( 212 | 986F172A2078094700FC39A5 /* LaunchScreen.storyboard in Resources */, 213 | 986F17272078094700FC39A5 /* Assets.xcassets in Resources */, 214 | 986F17252078094500FC39A5 /* Main.storyboard in Resources */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | 986F172E2078094700FC39A5 /* Resources */ = { 219 | isa = PBXResourcesBuildPhase; 220 | buildActionMask = 2147483647; 221 | files = ( 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | 986F17392078094700FC39A5 /* Resources */ = { 226 | isa = PBXResourcesBuildPhase; 227 | buildActionMask = 2147483647; 228 | files = ( 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXResourcesBuildPhase section */ 233 | 234 | /* Begin PBXSourcesBuildPhase section */ 235 | 986F17182078094500FC39A5 /* Sources */ = { 236 | isa = PBXSourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | 986F175020780DFD00FC39A5 /* MyCollectionViewController.swift in Sources */, 240 | 986F174E207809F700FC39A5 /* HorizontalPeekingPagesCollectionViewController.swift in Sources */, 241 | 986F17222078094500FC39A5 /* ViewController.swift in Sources */, 242 | 986F17202078094500FC39A5 /* AppDelegate.swift in Sources */, 243 | ); 244 | runOnlyForDeploymentPostprocessing = 0; 245 | }; 246 | 986F172C2078094700FC39A5 /* Sources */ = { 247 | isa = PBXSourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | }; 253 | 986F17372078094700FC39A5 /* Sources */ = { 254 | isa = PBXSourcesBuildPhase; 255 | buildActionMask = 2147483647; 256 | files = ( 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | /* End PBXSourcesBuildPhase section */ 261 | 262 | /* Begin PBXTargetDependency section */ 263 | 986F17322078094700FC39A5 /* PBXTargetDependency */ = { 264 | isa = PBXTargetDependency; 265 | target = 986F171B2078094500FC39A5 /* CollectionViewPeekingPages */; 266 | targetProxy = 986F17312078094700FC39A5 /* PBXContainerItemProxy */; 267 | }; 268 | 986F173D2078094700FC39A5 /* PBXTargetDependency */ = { 269 | isa = PBXTargetDependency; 270 | target = 986F171B2078094500FC39A5 /* CollectionViewPeekingPages */; 271 | targetProxy = 986F173C2078094700FC39A5 /* PBXContainerItemProxy */; 272 | }; 273 | /* End PBXTargetDependency section */ 274 | 275 | /* Begin PBXVariantGroup section */ 276 | 986F17232078094500FC39A5 /* Main.storyboard */ = { 277 | isa = PBXVariantGroup; 278 | children = ( 279 | 986F17242078094500FC39A5 /* Base */, 280 | ); 281 | name = Main.storyboard; 282 | sourceTree = ""; 283 | }; 284 | 986F17282078094700FC39A5 /* LaunchScreen.storyboard */ = { 285 | isa = PBXVariantGroup; 286 | children = ( 287 | 986F17292078094700FC39A5 /* Base */, 288 | ); 289 | name = LaunchScreen.storyboard; 290 | sourceTree = ""; 291 | }; 292 | /* End PBXVariantGroup section */ 293 | 294 | /* Begin XCBuildConfiguration section */ 295 | 986F17422078094700FC39A5 /* Debug */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ALWAYS_SEARCH_USER_PATHS = NO; 299 | CLANG_ANALYZER_NONNULL = YES; 300 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 301 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 302 | CLANG_CXX_LIBRARY = "libc++"; 303 | CLANG_ENABLE_MODULES = YES; 304 | CLANG_ENABLE_OBJC_ARC = YES; 305 | CLANG_ENABLE_OBJC_WEAK = YES; 306 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 307 | CLANG_WARN_BOOL_CONVERSION = YES; 308 | CLANG_WARN_COMMA = YES; 309 | CLANG_WARN_CONSTANT_CONVERSION = YES; 310 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 311 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 312 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 313 | CLANG_WARN_EMPTY_BODY = YES; 314 | CLANG_WARN_ENUM_CONVERSION = YES; 315 | CLANG_WARN_INFINITE_RECURSION = YES; 316 | CLANG_WARN_INT_CONVERSION = YES; 317 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 318 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 319 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 320 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 321 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 322 | CLANG_WARN_STRICT_PROTOTYPES = YES; 323 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 324 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 325 | CLANG_WARN_UNREACHABLE_CODE = YES; 326 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 327 | CODE_SIGN_IDENTITY = "iPhone Developer"; 328 | COPY_PHASE_STRIP = NO; 329 | DEBUG_INFORMATION_FORMAT = dwarf; 330 | ENABLE_STRICT_OBJC_MSGSEND = YES; 331 | ENABLE_TESTABILITY = YES; 332 | GCC_C_LANGUAGE_STANDARD = gnu11; 333 | GCC_DYNAMIC_NO_PIC = NO; 334 | GCC_NO_COMMON_BLOCKS = YES; 335 | GCC_OPTIMIZATION_LEVEL = 0; 336 | GCC_PREPROCESSOR_DEFINITIONS = ( 337 | "DEBUG=1", 338 | "$(inherited)", 339 | ); 340 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 341 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 342 | GCC_WARN_UNDECLARED_SELECTOR = YES; 343 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 344 | GCC_WARN_UNUSED_FUNCTION = YES; 345 | GCC_WARN_UNUSED_VARIABLE = YES; 346 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 347 | MTL_ENABLE_DEBUG_INFO = YES; 348 | ONLY_ACTIVE_ARCH = YES; 349 | SDKROOT = iphoneos; 350 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 351 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 352 | }; 353 | name = Debug; 354 | }; 355 | 986F17432078094700FC39A5 /* Release */ = { 356 | isa = XCBuildConfiguration; 357 | buildSettings = { 358 | ALWAYS_SEARCH_USER_PATHS = NO; 359 | CLANG_ANALYZER_NONNULL = YES; 360 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 361 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 362 | CLANG_CXX_LIBRARY = "libc++"; 363 | CLANG_ENABLE_MODULES = YES; 364 | CLANG_ENABLE_OBJC_ARC = YES; 365 | CLANG_ENABLE_OBJC_WEAK = YES; 366 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 367 | CLANG_WARN_BOOL_CONVERSION = YES; 368 | CLANG_WARN_COMMA = YES; 369 | CLANG_WARN_CONSTANT_CONVERSION = YES; 370 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 371 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 372 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 373 | CLANG_WARN_EMPTY_BODY = YES; 374 | CLANG_WARN_ENUM_CONVERSION = YES; 375 | CLANG_WARN_INFINITE_RECURSION = YES; 376 | CLANG_WARN_INT_CONVERSION = YES; 377 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 378 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 379 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 380 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 381 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 382 | CLANG_WARN_STRICT_PROTOTYPES = YES; 383 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 384 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 385 | CLANG_WARN_UNREACHABLE_CODE = YES; 386 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 387 | CODE_SIGN_IDENTITY = "iPhone Developer"; 388 | COPY_PHASE_STRIP = NO; 389 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 390 | ENABLE_NS_ASSERTIONS = NO; 391 | ENABLE_STRICT_OBJC_MSGSEND = YES; 392 | GCC_C_LANGUAGE_STANDARD = gnu11; 393 | GCC_NO_COMMON_BLOCKS = YES; 394 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 395 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 396 | GCC_WARN_UNDECLARED_SELECTOR = YES; 397 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 398 | GCC_WARN_UNUSED_FUNCTION = YES; 399 | GCC_WARN_UNUSED_VARIABLE = YES; 400 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 401 | MTL_ENABLE_DEBUG_INFO = NO; 402 | SDKROOT = iphoneos; 403 | SWIFT_COMPILATION_MODE = wholemodule; 404 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 405 | VALIDATE_PRODUCT = YES; 406 | }; 407 | name = Release; 408 | }; 409 | 986F17452078094700FC39A5 /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 413 | CODE_SIGN_STYLE = Automatic; 414 | DEVELOPMENT_TEAM = 85PYWN5SRP; 415 | INFOPLIST_FILE = CollectionViewPeekingPages/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = ( 417 | "$(inherited)", 418 | "@executable_path/Frameworks", 419 | ); 420 | PRODUCT_BUNDLE_IDENTIFIER = Hershalle.CollectionViewPeekingPages; 421 | PRODUCT_NAME = "$(TARGET_NAME)"; 422 | SWIFT_VERSION = 4.2; 423 | TARGETED_DEVICE_FAMILY = "1,2"; 424 | }; 425 | name = Debug; 426 | }; 427 | 986F17462078094700FC39A5 /* Release */ = { 428 | isa = XCBuildConfiguration; 429 | buildSettings = { 430 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 431 | CODE_SIGN_STYLE = Automatic; 432 | DEVELOPMENT_TEAM = 85PYWN5SRP; 433 | INFOPLIST_FILE = CollectionViewPeekingPages/Info.plist; 434 | LD_RUNPATH_SEARCH_PATHS = ( 435 | "$(inherited)", 436 | "@executable_path/Frameworks", 437 | ); 438 | PRODUCT_BUNDLE_IDENTIFIER = Hershalle.CollectionViewPeekingPages; 439 | PRODUCT_NAME = "$(TARGET_NAME)"; 440 | SWIFT_VERSION = 4.2; 441 | TARGETED_DEVICE_FAMILY = "1,2"; 442 | }; 443 | name = Release; 444 | }; 445 | 986F17482078094700FC39A5 /* Debug */ = { 446 | isa = XCBuildConfiguration; 447 | buildSettings = { 448 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 449 | BUNDLE_LOADER = "$(TEST_HOST)"; 450 | CODE_SIGN_STYLE = Automatic; 451 | DEVELOPMENT_TEAM = 85PYWN5SRP; 452 | INFOPLIST_FILE = CollectionViewPeekingPagesTests/Info.plist; 453 | LD_RUNPATH_SEARCH_PATHS = ( 454 | "$(inherited)", 455 | "@executable_path/Frameworks", 456 | "@loader_path/Frameworks", 457 | ); 458 | PRODUCT_BUNDLE_IDENTIFIER = Hershalle.CollectionViewPeekingPagesTests; 459 | PRODUCT_NAME = "$(TARGET_NAME)"; 460 | SWIFT_VERSION = 4.0; 461 | TARGETED_DEVICE_FAMILY = "1,2"; 462 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CollectionViewPeekingPages.app/CollectionViewPeekingPages"; 463 | }; 464 | name = Debug; 465 | }; 466 | 986F17492078094700FC39A5 /* Release */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 470 | BUNDLE_LOADER = "$(TEST_HOST)"; 471 | CODE_SIGN_STYLE = Automatic; 472 | DEVELOPMENT_TEAM = 85PYWN5SRP; 473 | INFOPLIST_FILE = CollectionViewPeekingPagesTests/Info.plist; 474 | LD_RUNPATH_SEARCH_PATHS = ( 475 | "$(inherited)", 476 | "@executable_path/Frameworks", 477 | "@loader_path/Frameworks", 478 | ); 479 | PRODUCT_BUNDLE_IDENTIFIER = Hershalle.CollectionViewPeekingPagesTests; 480 | PRODUCT_NAME = "$(TARGET_NAME)"; 481 | SWIFT_VERSION = 4.0; 482 | TARGETED_DEVICE_FAMILY = "1,2"; 483 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CollectionViewPeekingPages.app/CollectionViewPeekingPages"; 484 | }; 485 | name = Release; 486 | }; 487 | 986F174B2078094700FC39A5 /* Debug */ = { 488 | isa = XCBuildConfiguration; 489 | buildSettings = { 490 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 491 | CODE_SIGN_STYLE = Automatic; 492 | DEVELOPMENT_TEAM = 85PYWN5SRP; 493 | INFOPLIST_FILE = CollectionViewPeekingPagesUITests/Info.plist; 494 | LD_RUNPATH_SEARCH_PATHS = ( 495 | "$(inherited)", 496 | "@executable_path/Frameworks", 497 | "@loader_path/Frameworks", 498 | ); 499 | PRODUCT_BUNDLE_IDENTIFIER = Hershalle.CollectionViewPeekingPagesUITests; 500 | PRODUCT_NAME = "$(TARGET_NAME)"; 501 | SWIFT_VERSION = 4.0; 502 | TARGETED_DEVICE_FAMILY = "1,2"; 503 | TEST_TARGET_NAME = CollectionViewPeekingPages; 504 | }; 505 | name = Debug; 506 | }; 507 | 986F174C2078094700FC39A5 /* Release */ = { 508 | isa = XCBuildConfiguration; 509 | buildSettings = { 510 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 511 | CODE_SIGN_STYLE = Automatic; 512 | DEVELOPMENT_TEAM = 85PYWN5SRP; 513 | INFOPLIST_FILE = CollectionViewPeekingPagesUITests/Info.plist; 514 | LD_RUNPATH_SEARCH_PATHS = ( 515 | "$(inherited)", 516 | "@executable_path/Frameworks", 517 | "@loader_path/Frameworks", 518 | ); 519 | PRODUCT_BUNDLE_IDENTIFIER = Hershalle.CollectionViewPeekingPagesUITests; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | SWIFT_VERSION = 4.0; 522 | TARGETED_DEVICE_FAMILY = "1,2"; 523 | TEST_TARGET_NAME = CollectionViewPeekingPages; 524 | }; 525 | name = Release; 526 | }; 527 | /* End XCBuildConfiguration section */ 528 | 529 | /* Begin XCConfigurationList section */ 530 | 986F17172078094500FC39A5 /* Build configuration list for PBXProject "CollectionViewPeekingPages" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 986F17422078094700FC39A5 /* Debug */, 534 | 986F17432078094700FC39A5 /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | defaultConfigurationName = Release; 538 | }; 539 | 986F17442078094700FC39A5 /* Build configuration list for PBXNativeTarget "CollectionViewPeekingPages" */ = { 540 | isa = XCConfigurationList; 541 | buildConfigurations = ( 542 | 986F17452078094700FC39A5 /* Debug */, 543 | 986F17462078094700FC39A5 /* Release */, 544 | ); 545 | defaultConfigurationIsVisible = 0; 546 | defaultConfigurationName = Release; 547 | }; 548 | 986F17472078094700FC39A5 /* Build configuration list for PBXNativeTarget "CollectionViewPeekingPagesTests" */ = { 549 | isa = XCConfigurationList; 550 | buildConfigurations = ( 551 | 986F17482078094700FC39A5 /* Debug */, 552 | 986F17492078094700FC39A5 /* Release */, 553 | ); 554 | defaultConfigurationIsVisible = 0; 555 | defaultConfigurationName = Release; 556 | }; 557 | 986F174A2078094700FC39A5 /* Build configuration list for PBXNativeTarget "CollectionViewPeekingPagesUITests" */ = { 558 | isa = XCConfigurationList; 559 | buildConfigurations = ( 560 | 986F174B2078094700FC39A5 /* Debug */, 561 | 986F174C2078094700FC39A5 /* Release */, 562 | ); 563 | defaultConfigurationIsVisible = 0; 564 | defaultConfigurationName = Release; 565 | }; 566 | /* End XCConfigurationList section */ 567 | }; 568 | rootObject = 986F17142078094500FC39A5 /* Project object */; 569 | } 570 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CollectionViewPeekingPages 4 | // 5 | // Created by Shai Balassiano on 06/04/2018. 6 | // Copyright © 2018 Shai Balassiano. 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: [UIApplication.LaunchOptionsKey: 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 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages/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 | } -------------------------------------------------------------------------------- /CollectionViewPeekingPages/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CollectionViewPeekingPages/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 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages/HorizontalPeekingPagesCollectionViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewPeekingPages.swift 3 | // CollectionViewPeekingPages 4 | // 5 | // Created by Shai Balassiano on 06/04/2018. 6 | // Copyright © 2018 Shai Balassiano. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class HorizontalPeekingPagesCollectionViewController: UICollectionViewController { 12 | private var indexOfCellBeforeDragging = 0 13 | private var collectionViewFlowLayout: UICollectionViewFlowLayout { 14 | return collectionViewLayout as! UICollectionViewFlowLayout 15 | } 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | collectionViewFlowLayout.minimumLineSpacing = 0 21 | } 22 | 23 | override func viewDidLayoutSubviews() { 24 | super.viewDidLayoutSubviews() 25 | 26 | configureCollectionViewLayoutItemSize() 27 | } 28 | 29 | func calculateSectionInset() -> CGFloat { // should be overridden 30 | return 100 31 | } 32 | 33 | private func configureCollectionViewLayoutItemSize() { 34 | let inset: CGFloat = calculateSectionInset() 35 | collectionViewFlowLayout.sectionInset = UIEdgeInsets(top: 0, left: inset, bottom: 0, right: inset) 36 | 37 | collectionViewFlowLayout.itemSize = CGSize(width: collectionViewLayout.collectionView!.frame.size.width - inset * 2, height: collectionViewLayout.collectionView!.frame.size.height) 38 | } 39 | 40 | private func indexOfMajorCell() -> Int { 41 | let itemWidth = collectionViewFlowLayout.itemSize.width 42 | let proportionalOffset = collectionViewLayout.collectionView!.contentOffset.x / itemWidth 43 | let index = Int(round(proportionalOffset)) 44 | let numberOfItems = collectionView.numberOfItems(inSection: 0) 45 | let safeIndex = max(0, min(numberOfItems - 1, index)) 46 | return safeIndex 47 | } 48 | 49 | override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { 50 | indexOfCellBeforeDragging = indexOfMajorCell() 51 | } 52 | 53 | override func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) { 54 | // Stop scrollView sliding: 55 | targetContentOffset.pointee = scrollView.contentOffset 56 | 57 | // calculate where scrollView should snap to: 58 | let indexOfMajorCell = self.indexOfMajorCell() 59 | 60 | // calculate conditions: 61 | let dataSourceCount = collectionView(collectionView!, numberOfItemsInSection: 0) 62 | let swipeVelocityThreshold: CGFloat = 0.5 // after some trail and error 63 | let hasEnoughVelocityToSlideToTheNextCell = indexOfCellBeforeDragging + 1 < dataSourceCount && velocity.x > swipeVelocityThreshold 64 | let hasEnoughVelocityToSlideToThePreviousCell = indexOfCellBeforeDragging - 1 >= 0 && velocity.x < -swipeVelocityThreshold 65 | let majorCellIsTheCellBeforeDragging = indexOfMajorCell == indexOfCellBeforeDragging 66 | let didUseSwipeToSkipCell = majorCellIsTheCellBeforeDragging && (hasEnoughVelocityToSlideToTheNextCell || hasEnoughVelocityToSlideToThePreviousCell) 67 | 68 | if didUseSwipeToSkipCell { 69 | 70 | let snapToIndex = indexOfCellBeforeDragging + (hasEnoughVelocityToSlideToTheNextCell ? 1 : -1) 71 | let toValue = collectionViewFlowLayout.itemSize.width * CGFloat(snapToIndex) 72 | 73 | // Damping equal 1 => no oscillations => decay animation: 74 | UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: velocity.x, options: .allowUserInteraction, animations: { 75 | scrollView.contentOffset = CGPoint(x: toValue, y: 0) 76 | scrollView.layoutIfNeeded() 77 | }, completion: nil) 78 | 79 | } else { 80 | // This is a much better way to scroll to a cell: 81 | let indexPath = IndexPath(row: indexOfMajorCell, section: 0) 82 | collectionViewLayout.collectionView!.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages/MyCollectionViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyCollectionViewController.swift 3 | // CollectionViewPeekingPages 4 | // 5 | // Created by Shai Balassiano on 06/04/2018. 6 | // Copyright © 2018 Shai Balassiano. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MyCollectionViewController: HorizontalPeekingPagesCollectionViewController { 12 | 13 | var dataSource = [0, 1, 2, 3, 4, 5, 6] { 14 | didSet { 15 | collectionView?.reloadData() 16 | } 17 | } 18 | 19 | override func calculateSectionInset() -> CGFloat { 20 | return 40 21 | } 22 | 23 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 24 | return dataSource.count 25 | } 26 | 27 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 28 | return collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CollectionViewPeekingPages/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CollectionViewPeekingPages 4 | // 5 | // Created by Shai Balassiano on 06/04/2018. 6 | // Copyright © 2018 Shai Balassiano. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | // var myCollectionViewController: MyCollectionViewController! 14 | // override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 15 | // if let myCollectionViewController = segue.destination as? MyCollectionViewController { 16 | // self.myCollectionViewController = myCollectionViewController 17 | // } 18 | // } 19 | // 20 | // override func viewDidAppear(_ animated: Bool) { 21 | // super.viewDidAppear(animated) 22 | // 23 | // myCollectionViewController.dataSource = [0, 1, 2, 3, 4, 5, 6] 24 | // } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Shai Balassiano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Horizontal UICollectionView with peeking pages 2 | 3 | 4 | This repo shows a simpler version of the [finished example](https://github.com/hershalle/CollectionViewWithPaging-Finish) of this [tutorial](https://medium.com/@shaibalassiano/tutorial-horizontal-uicollectionview-with-paging-9421b479ee94) on how to build a horizontal UICollectionView with peeking pages. 5 | 6 | This simpler version is almost a plug and play. 7 | Check it out! 8 | 9 | ## Comments: 10 | If you have any comments you can open an issue and tell me what you think. You can also contact me via Twitter [@hershalle](https://twitter.com/hershalle) --------------------------------------------------------------------------------