├── CollectionViewPagingExample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── Jin-TaeWoo.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── Jin-TaeWoo.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── CollectionViewPagingExample ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── CollectionViewCell.swift ├── Info.plist ├── Supporting Files │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ └── Info.plist └── ViewController.swift ├── CollectionViewPagingExampleUITests ├── CollectionViewPagingExampleUITests.swift └── Info.plist └── README.md /CollectionViewPagingExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 748D135F24BC41BF007A47D5 /* TestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 748D135E24BC41BF007A47D5 /* TestViewController.swift */; }; 11 | FC552388210185680099FAA4 /* CollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC552387210185680099FAA4 /* CollectionViewCell.swift */; }; 12 | FC95FC9320FED8B700E53C5E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC95FC9220FED8B700E53C5E /* AppDelegate.swift */; }; 13 | FC95FC9520FED8B700E53C5E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC95FC9420FED8B700E53C5E /* ViewController.swift */; }; 14 | FC95FC9820FED8B700E53C5E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC95FC9620FED8B700E53C5E /* Main.storyboard */; }; 15 | FC95FC9A20FED8BA00E53C5E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FC95FC9920FED8BA00E53C5E /* Assets.xcassets */; }; 16 | FC95FC9D20FED8BA00E53C5E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = FC95FC9B20FED8BA00E53C5E /* LaunchScreen.storyboard */; }; 17 | FC95FCA820FED8BB00E53C5E /* CollectionViewPagingExampleUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FC95FCA720FED8BB00E53C5E /* CollectionViewPagingExampleUITests.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | FC95FCA420FED8BB00E53C5E /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = FC95FC8720FED8B700E53C5E /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = FC95FC8E20FED8B700E53C5E; 26 | remoteInfo = CollectionViewPagingExample; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 748D135E24BC41BF007A47D5 /* TestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestViewController.swift; sourceTree = ""; }; 32 | FC552387210185680099FAA4 /* CollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewCell.swift; sourceTree = ""; }; 33 | FC95FC8F20FED8B700E53C5E /* CollectionViewPagingExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionViewPagingExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | FC95FC9220FED8B700E53C5E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 35 | FC95FC9420FED8B700E53C5E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 36 | FC95FC9720FED8B700E53C5E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 37 | FC95FC9920FED8BA00E53C5E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 38 | FC95FC9C20FED8BA00E53C5E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 39 | FC95FC9E20FED8BA00E53C5E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | FC95FCA320FED8BB00E53C5E /* CollectionViewPagingExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CollectionViewPagingExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | FC95FCA720FED8BB00E53C5E /* CollectionViewPagingExampleUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewPagingExampleUITests.swift; sourceTree = ""; }; 42 | FC95FCA920FED8BB00E53C5E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | /* End PBXFileReference section */ 44 | 45 | /* Begin PBXFrameworksBuildPhase section */ 46 | FC95FC8C20FED8B700E53C5E /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | FC95FCA020FED8BB00E53C5E /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 0; 59 | }; 60 | /* End PBXFrameworksBuildPhase section */ 61 | 62 | /* Begin PBXGroup section */ 63 | 748D135D24BC3B6F007A47D5 /* Supporting Files */ = { 64 | isa = PBXGroup; 65 | children = ( 66 | FC95FC9920FED8BA00E53C5E /* Assets.xcassets */, 67 | FC95FC9620FED8B700E53C5E /* Main.storyboard */, 68 | FC95FC9B20FED8BA00E53C5E /* LaunchScreen.storyboard */, 69 | FC95FC9E20FED8BA00E53C5E /* Info.plist */, 70 | ); 71 | path = "Supporting Files"; 72 | sourceTree = ""; 73 | }; 74 | FC95FC8620FED8B700E53C5E = { 75 | isa = PBXGroup; 76 | children = ( 77 | FC95FC9120FED8B700E53C5E /* CollectionViewPagingExample */, 78 | FC95FCA620FED8BB00E53C5E /* CollectionViewPagingExampleUITests */, 79 | FC95FC9020FED8B700E53C5E /* Products */, 80 | ); 81 | sourceTree = ""; 82 | }; 83 | FC95FC9020FED8B700E53C5E /* Products */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | FC95FC8F20FED8B700E53C5E /* CollectionViewPagingExample.app */, 87 | FC95FCA320FED8BB00E53C5E /* CollectionViewPagingExampleUITests.xctest */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | FC95FC9120FED8B700E53C5E /* CollectionViewPagingExample */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 748D135D24BC3B6F007A47D5 /* Supporting Files */, 96 | FC95FC9220FED8B700E53C5E /* AppDelegate.swift */, 97 | FC95FC9420FED8B700E53C5E /* ViewController.swift */, 98 | 748D135E24BC41BF007A47D5 /* TestViewController.swift */, 99 | FC552387210185680099FAA4 /* CollectionViewCell.swift */, 100 | ); 101 | path = CollectionViewPagingExample; 102 | sourceTree = ""; 103 | }; 104 | FC95FCA620FED8BB00E53C5E /* CollectionViewPagingExampleUITests */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | FC95FCA720FED8BB00E53C5E /* CollectionViewPagingExampleUITests.swift */, 108 | FC95FCA920FED8BB00E53C5E /* Info.plist */, 109 | ); 110 | path = CollectionViewPagingExampleUITests; 111 | sourceTree = ""; 112 | }; 113 | /* End PBXGroup section */ 114 | 115 | /* Begin PBXNativeTarget section */ 116 | FC95FC8E20FED8B700E53C5E /* CollectionViewPagingExample */ = { 117 | isa = PBXNativeTarget; 118 | buildConfigurationList = FC95FCAC20FED8BB00E53C5E /* Build configuration list for PBXNativeTarget "CollectionViewPagingExample" */; 119 | buildPhases = ( 120 | FC95FC8B20FED8B700E53C5E /* Sources */, 121 | FC95FC8C20FED8B700E53C5E /* Frameworks */, 122 | FC95FC8D20FED8B700E53C5E /* Resources */, 123 | ); 124 | buildRules = ( 125 | ); 126 | dependencies = ( 127 | ); 128 | name = CollectionViewPagingExample; 129 | productName = CollectionViewPagingExample; 130 | productReference = FC95FC8F20FED8B700E53C5E /* CollectionViewPagingExample.app */; 131 | productType = "com.apple.product-type.application"; 132 | }; 133 | FC95FCA220FED8BB00E53C5E /* CollectionViewPagingExampleUITests */ = { 134 | isa = PBXNativeTarget; 135 | buildConfigurationList = FC95FCAF20FED8BB00E53C5E /* Build configuration list for PBXNativeTarget "CollectionViewPagingExampleUITests" */; 136 | buildPhases = ( 137 | FC95FC9F20FED8BB00E53C5E /* Sources */, 138 | FC95FCA020FED8BB00E53C5E /* Frameworks */, 139 | FC95FCA120FED8BB00E53C5E /* Resources */, 140 | ); 141 | buildRules = ( 142 | ); 143 | dependencies = ( 144 | FC95FCA520FED8BB00E53C5E /* PBXTargetDependency */, 145 | ); 146 | name = CollectionViewPagingExampleUITests; 147 | productName = CollectionViewPagingExampleUITests; 148 | productReference = FC95FCA320FED8BB00E53C5E /* CollectionViewPagingExampleUITests.xctest */; 149 | productType = "com.apple.product-type.bundle.ui-testing"; 150 | }; 151 | /* End PBXNativeTarget section */ 152 | 153 | /* Begin PBXProject section */ 154 | FC95FC8720FED8B700E53C5E /* Project object */ = { 155 | isa = PBXProject; 156 | attributes = { 157 | LastSwiftUpdateCheck = 0940; 158 | LastUpgradeCheck = 0940; 159 | ORGANIZATIONNAME = "진용호"; 160 | TargetAttributes = { 161 | FC95FC8E20FED8B700E53C5E = { 162 | CreatedOnToolsVersion = 9.4.1; 163 | }; 164 | FC95FCA220FED8BB00E53C5E = { 165 | CreatedOnToolsVersion = 9.4.1; 166 | TestTargetID = FC95FC8E20FED8B700E53C5E; 167 | }; 168 | }; 169 | }; 170 | buildConfigurationList = FC95FC8A20FED8B700E53C5E /* Build configuration list for PBXProject "CollectionViewPagingExample" */; 171 | compatibilityVersion = "Xcode 9.3"; 172 | developmentRegion = en; 173 | hasScannedForEncodings = 0; 174 | knownRegions = ( 175 | en, 176 | Base, 177 | ); 178 | mainGroup = FC95FC8620FED8B700E53C5E; 179 | productRefGroup = FC95FC9020FED8B700E53C5E /* Products */; 180 | projectDirPath = ""; 181 | projectRoot = ""; 182 | targets = ( 183 | FC95FC8E20FED8B700E53C5E /* CollectionViewPagingExample */, 184 | FC95FCA220FED8BB00E53C5E /* CollectionViewPagingExampleUITests */, 185 | ); 186 | }; 187 | /* End PBXProject section */ 188 | 189 | /* Begin PBXResourcesBuildPhase section */ 190 | FC95FC8D20FED8B700E53C5E /* Resources */ = { 191 | isa = PBXResourcesBuildPhase; 192 | buildActionMask = 2147483647; 193 | files = ( 194 | FC95FC9D20FED8BA00E53C5E /* LaunchScreen.storyboard in Resources */, 195 | FC95FC9A20FED8BA00E53C5E /* Assets.xcassets in Resources */, 196 | FC95FC9820FED8B700E53C5E /* Main.storyboard in Resources */, 197 | ); 198 | runOnlyForDeploymentPostprocessing = 0; 199 | }; 200 | FC95FCA120FED8BB00E53C5E /* Resources */ = { 201 | isa = PBXResourcesBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | FC95FC8B20FED8B700E53C5E /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | FC95FC9520FED8B700E53C5E /* ViewController.swift in Sources */, 215 | FC95FC9320FED8B700E53C5E /* AppDelegate.swift in Sources */, 216 | 748D135F24BC41BF007A47D5 /* TestViewController.swift in Sources */, 217 | FC552388210185680099FAA4 /* CollectionViewCell.swift in Sources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | FC95FC9F20FED8BB00E53C5E /* Sources */ = { 222 | isa = PBXSourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | FC95FCA820FED8BB00E53C5E /* CollectionViewPagingExampleUITests.swift in Sources */, 226 | ); 227 | runOnlyForDeploymentPostprocessing = 0; 228 | }; 229 | /* End PBXSourcesBuildPhase section */ 230 | 231 | /* Begin PBXTargetDependency section */ 232 | FC95FCA520FED8BB00E53C5E /* PBXTargetDependency */ = { 233 | isa = PBXTargetDependency; 234 | target = FC95FC8E20FED8B700E53C5E /* CollectionViewPagingExample */; 235 | targetProxy = FC95FCA420FED8BB00E53C5E /* PBXContainerItemProxy */; 236 | }; 237 | /* End PBXTargetDependency section */ 238 | 239 | /* Begin PBXVariantGroup section */ 240 | FC95FC9620FED8B700E53C5E /* Main.storyboard */ = { 241 | isa = PBXVariantGroup; 242 | children = ( 243 | FC95FC9720FED8B700E53C5E /* Base */, 244 | ); 245 | name = Main.storyboard; 246 | sourceTree = ""; 247 | }; 248 | FC95FC9B20FED8BA00E53C5E /* LaunchScreen.storyboard */ = { 249 | isa = PBXVariantGroup; 250 | children = ( 251 | FC95FC9C20FED8BA00E53C5E /* Base */, 252 | ); 253 | name = LaunchScreen.storyboard; 254 | sourceTree = ""; 255 | }; 256 | /* End PBXVariantGroup section */ 257 | 258 | /* Begin XCBuildConfiguration section */ 259 | FC95FCAA20FED8BB00E53C5E /* Debug */ = { 260 | isa = XCBuildConfiguration; 261 | buildSettings = { 262 | ALWAYS_SEARCH_USER_PATHS = NO; 263 | CLANG_ANALYZER_NONNULL = YES; 264 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 265 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 266 | CLANG_CXX_LIBRARY = "libc++"; 267 | CLANG_ENABLE_MODULES = YES; 268 | CLANG_ENABLE_OBJC_ARC = YES; 269 | CLANG_ENABLE_OBJC_WEAK = YES; 270 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_COMMA = YES; 273 | CLANG_WARN_CONSTANT_CONVERSION = YES; 274 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 275 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 276 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 277 | CLANG_WARN_EMPTY_BODY = YES; 278 | CLANG_WARN_ENUM_CONVERSION = YES; 279 | CLANG_WARN_INFINITE_RECURSION = YES; 280 | CLANG_WARN_INT_CONVERSION = YES; 281 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 282 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 283 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 284 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 285 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 286 | CLANG_WARN_STRICT_PROTOTYPES = YES; 287 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 288 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 289 | CLANG_WARN_UNREACHABLE_CODE = YES; 290 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 291 | CODE_SIGN_IDENTITY = "iPhone Developer"; 292 | COPY_PHASE_STRIP = NO; 293 | DEBUG_INFORMATION_FORMAT = dwarf; 294 | ENABLE_STRICT_OBJC_MSGSEND = YES; 295 | ENABLE_TESTABILITY = YES; 296 | GCC_C_LANGUAGE_STANDARD = gnu11; 297 | GCC_DYNAMIC_NO_PIC = NO; 298 | GCC_NO_COMMON_BLOCKS = YES; 299 | GCC_OPTIMIZATION_LEVEL = 0; 300 | GCC_PREPROCESSOR_DEFINITIONS = ( 301 | "DEBUG=1", 302 | "$(inherited)", 303 | ); 304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 306 | GCC_WARN_UNDECLARED_SELECTOR = YES; 307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 308 | GCC_WARN_UNUSED_FUNCTION = YES; 309 | GCC_WARN_UNUSED_VARIABLE = YES; 310 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 311 | MTL_ENABLE_DEBUG_INFO = YES; 312 | ONLY_ACTIVE_ARCH = YES; 313 | SDKROOT = iphoneos; 314 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 315 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 316 | }; 317 | name = Debug; 318 | }; 319 | FC95FCAB20FED8BB00E53C5E /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CLANG_ANALYZER_NONNULL = YES; 324 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 325 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 326 | CLANG_CXX_LIBRARY = "libc++"; 327 | CLANG_ENABLE_MODULES = YES; 328 | CLANG_ENABLE_OBJC_ARC = YES; 329 | CLANG_ENABLE_OBJC_WEAK = YES; 330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_COMMA = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 335 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 336 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 337 | CLANG_WARN_EMPTY_BODY = YES; 338 | CLANG_WARN_ENUM_CONVERSION = YES; 339 | CLANG_WARN_INFINITE_RECURSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 343 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 346 | CLANG_WARN_STRICT_PROTOTYPES = YES; 347 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 348 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 349 | CLANG_WARN_UNREACHABLE_CODE = YES; 350 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 351 | CODE_SIGN_IDENTITY = "iPhone Developer"; 352 | COPY_PHASE_STRIP = NO; 353 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 354 | ENABLE_NS_ASSERTIONS = NO; 355 | ENABLE_STRICT_OBJC_MSGSEND = YES; 356 | GCC_C_LANGUAGE_STANDARD = gnu11; 357 | GCC_NO_COMMON_BLOCKS = YES; 358 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 359 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 360 | GCC_WARN_UNDECLARED_SELECTOR = YES; 361 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 362 | GCC_WARN_UNUSED_FUNCTION = YES; 363 | GCC_WARN_UNUSED_VARIABLE = YES; 364 | IPHONEOS_DEPLOYMENT_TARGET = 11.4; 365 | MTL_ENABLE_DEBUG_INFO = NO; 366 | SDKROOT = iphoneos; 367 | SWIFT_COMPILATION_MODE = wholemodule; 368 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 369 | VALIDATE_PRODUCT = YES; 370 | }; 371 | name = Release; 372 | }; 373 | FC95FCAD20FED8BB00E53C5E /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 377 | CODE_SIGN_STYLE = Automatic; 378 | DEVELOPMENT_TEAM = 22VQ353X6R; 379 | INFOPLIST_FILE = "CollectionViewPagingExample/Supporting Files/Info.plist"; 380 | LD_RUNPATH_SEARCH_PATHS = ( 381 | "$(inherited)", 382 | "@executable_path/Frameworks", 383 | ); 384 | PRODUCT_BUNDLE_IDENTIFIER = kr.jin.CollectionViewPagingExample; 385 | PRODUCT_NAME = "$(TARGET_NAME)"; 386 | SWIFT_VERSION = 4.0; 387 | TARGETED_DEVICE_FAMILY = "1,2"; 388 | }; 389 | name = Debug; 390 | }; 391 | FC95FCAE20FED8BB00E53C5E /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 395 | CODE_SIGN_STYLE = Automatic; 396 | DEVELOPMENT_TEAM = 22VQ353X6R; 397 | INFOPLIST_FILE = "CollectionViewPagingExample/Supporting Files/Info.plist"; 398 | LD_RUNPATH_SEARCH_PATHS = ( 399 | "$(inherited)", 400 | "@executable_path/Frameworks", 401 | ); 402 | PRODUCT_BUNDLE_IDENTIFIER = kr.jin.CollectionViewPagingExample; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | SWIFT_VERSION = 4.0; 405 | TARGETED_DEVICE_FAMILY = "1,2"; 406 | }; 407 | name = Release; 408 | }; 409 | FC95FCB020FED8BB00E53C5E /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 413 | CODE_SIGN_STYLE = Automatic; 414 | DEVELOPMENT_TEAM = 22VQ353X6R; 415 | INFOPLIST_FILE = CollectionViewPagingExampleUITests/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = ( 417 | "$(inherited)", 418 | "@executable_path/Frameworks", 419 | "@loader_path/Frameworks", 420 | ); 421 | PRODUCT_BUNDLE_IDENTIFIER = kr.jin.CollectionViewPagingExampleUITests; 422 | PRODUCT_NAME = "$(TARGET_NAME)"; 423 | SWIFT_VERSION = 4.0; 424 | TARGETED_DEVICE_FAMILY = "1,2"; 425 | TEST_TARGET_NAME = CollectionViewPagingExample; 426 | }; 427 | name = Debug; 428 | }; 429 | FC95FCB120FED8BB00E53C5E /* Release */ = { 430 | isa = XCBuildConfiguration; 431 | buildSettings = { 432 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 433 | CODE_SIGN_STYLE = Automatic; 434 | DEVELOPMENT_TEAM = 22VQ353X6R; 435 | INFOPLIST_FILE = CollectionViewPagingExampleUITests/Info.plist; 436 | LD_RUNPATH_SEARCH_PATHS = ( 437 | "$(inherited)", 438 | "@executable_path/Frameworks", 439 | "@loader_path/Frameworks", 440 | ); 441 | PRODUCT_BUNDLE_IDENTIFIER = kr.jin.CollectionViewPagingExampleUITests; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | SWIFT_VERSION = 4.0; 444 | TARGETED_DEVICE_FAMILY = "1,2"; 445 | TEST_TARGET_NAME = CollectionViewPagingExample; 446 | }; 447 | name = Release; 448 | }; 449 | /* End XCBuildConfiguration section */ 450 | 451 | /* Begin XCConfigurationList section */ 452 | FC95FC8A20FED8B700E53C5E /* Build configuration list for PBXProject "CollectionViewPagingExample" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | FC95FCAA20FED8BB00E53C5E /* Debug */, 456 | FC95FCAB20FED8BB00E53C5E /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | FC95FCAC20FED8BB00E53C5E /* Build configuration list for PBXNativeTarget "CollectionViewPagingExample" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | FC95FCAD20FED8BB00E53C5E /* Debug */, 465 | FC95FCAE20FED8BB00E53C5E /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | FC95FCAF20FED8BB00E53C5E /* Build configuration list for PBXNativeTarget "CollectionViewPagingExampleUITests" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | FC95FCB020FED8BB00E53C5E /* Debug */, 474 | FC95FCB120FED8BB00E53C5E /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | defaultConfigurationName = Release; 478 | }; 479 | /* End XCConfigurationList section */ 480 | }; 481 | rootObject = FC95FC8720FED8B700E53C5E /* Project object */; 482 | } 483 | -------------------------------------------------------------------------------- /CollectionViewPagingExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CollectionViewPagingExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CollectionViewPagingExample.xcodeproj/project.xcworkspace/xcuserdata/Jin-TaeWoo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taewoojin/CollectionViewPagingExample/494aa658056062c1579f272d83f9e561ea339212/CollectionViewPagingExample.xcodeproj/project.xcworkspace/xcuserdata/Jin-TaeWoo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /CollectionViewPagingExample.xcodeproj/xcuserdata/Jin-TaeWoo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /CollectionViewPagingExample.xcodeproj/xcuserdata/Jin-TaeWoo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | CollectionViewPagingExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CollectionViewPagingExample 4 | // 5 | // Created by 진용호 on 2018. 7. 18.. 6 | // Copyright © 2018년 진용호. 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 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/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 | } -------------------------------------------------------------------------------- /CollectionViewPagingExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CollectionViewPagingExample/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 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/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 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/CollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewCell.swift 3 | // CollectionViewPagingExample 4 | // 5 | // Created by 진용호 on 2018. 7. 20.. 6 | // Copyright © 2018년 진용호. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CollectionViewCell: UICollectionViewCell { 12 | 13 | override func layoutSubviews() { 14 | super.layoutSubviews() 15 | self.layer.cornerRadius = 3.0 16 | layer.shadowRadius = 10 17 | layer.shadowOpacity = 0.4 18 | layer.shadowOffset = CGSize(width: 5, height: 10) 19 | self.clipsToBounds = false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/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 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/Supporting Files/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 | } -------------------------------------------------------------------------------- /CollectionViewPagingExample/Supporting Files/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /CollectionViewPagingExample/Supporting Files/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 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/Supporting Files/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 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/Supporting Files/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 | -------------------------------------------------------------------------------- /CollectionViewPagingExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CollectionViewPagingExample 4 | // 5 | // Created by 진용호 on 2018. 7. 18.. 6 | // Copyright © 2018년 진용호. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var collectionView: UICollectionView! 14 | 15 | let itemColors = [UIColor.red, UIColor.yellow, UIColor.blue, UIColor.green] 16 | 17 | var currentIndex: CGFloat = 0 18 | 19 | let lineSpacing: CGFloat = 20 20 | 21 | let cellRatio: CGFloat = 0.7 22 | 23 | var isOneStepPaging = true 24 | 25 | 26 | override func viewDidLoad() { 27 | super.viewDidLoad() 28 | 29 | // width, height 설정 30 | let cellWidth = floor(view.frame.width * cellRatio) 31 | let cellHeight = floor(view.frame.height * cellRatio) 32 | 33 | // 상하, 좌우 inset value 설정 34 | let insetX = (view.bounds.width - cellWidth) / 2.0 35 | let insetY = (view.bounds.height - cellHeight) / 2.0 36 | 37 | let layout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout 38 | layout.itemSize = CGSize(width: cellWidth, height: cellHeight) 39 | layout.minimumLineSpacing = lineSpacing 40 | layout.scrollDirection = .horizontal 41 | collectionView.contentInset = UIEdgeInsets(top: insetY, left: insetX, bottom: insetY, right: insetX) 42 | 43 | collectionView.delegate = self 44 | collectionView.dataSource = self 45 | 46 | // 스크롤 시 빠르게 감속 되도록 설정 47 | collectionView.decelerationRate = UIScrollViewDecelerationRateFast 48 | } 49 | 50 | } 51 | 52 | extension ViewController: UICollectionViewDataSource, UICollectionViewDelegate { 53 | func numberOfSections(in collectionView: UICollectionView) -> Int { 54 | return 1 55 | } 56 | 57 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 58 | return itemColors.count 59 | } 60 | 61 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 62 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collectionViewCell", for: indexPath) as! CollectionViewCell 63 | cell.backgroundColor = itemColors[indexPath.row] 64 | cell.alpha = 0.5 65 | return cell 66 | } 67 | 68 | } 69 | 70 | extension ViewController : UIScrollViewDelegate { 71 | 72 | func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) 73 | { 74 | // item의 사이즈와 item 간의 간격 사이즈를 구해서 하나의 item 크기로 설정. 75 | let layout = self.collectionView.collectionViewLayout as! UICollectionViewFlowLayout 76 | let cellWidthIncludingSpacing = layout.itemSize.width + layout.minimumLineSpacing 77 | 78 | // targetContentOff을 이용하여 x좌표가 얼마나 이동했는지 확인 79 | // 이동한 x좌표 값과 item의 크기를 비교하여 몇 페이징이 될 것인지 값 설정 80 | var offset = targetContentOffset.pointee 81 | let index = (offset.x + scrollView.contentInset.left) / cellWidthIncludingSpacing 82 | var roundedIndex = round(index) 83 | 84 | // scrollView, targetContentOffset의 좌표 값으로 스크롤 방향을 알 수 있다. 85 | // index를 반올림하여 사용하면 item의 절반 사이즈만큼 스크롤을 해야 페이징이 된다. 86 | // 스크로로 방향을 체크하여 올림,내림을 사용하면 좀 더 자연스러운 페이징 효과를 낼 수 있다. 87 | if scrollView.contentOffset.x > targetContentOffset.pointee.x { 88 | roundedIndex = floor(index) 89 | } else if scrollView.contentOffset.x < targetContentOffset.pointee.x { 90 | roundedIndex = ceil(index) 91 | } else { 92 | roundedIndex = round(index) 93 | } 94 | 95 | if isOneStepPaging { 96 | if currentIndex > roundedIndex { 97 | currentIndex -= 1 98 | roundedIndex = currentIndex 99 | } else if currentIndex < roundedIndex { 100 | currentIndex += 1 101 | roundedIndex = currentIndex 102 | } 103 | } 104 | 105 | // 위 코드를 통해 페이징 될 좌표값을 targetContentOffset에 대입하면 된다. 106 | offset = CGPoint(x: roundedIndex * cellWidthIncludingSpacing - scrollView.contentInset.left, y: -scrollView.contentInset.top) 107 | targetContentOffset.pointee = offset 108 | } 109 | } 110 | 111 | -------------------------------------------------------------------------------- /CollectionViewPagingExampleUITests/CollectionViewPagingExampleUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionViewPagingExampleUITests.swift 3 | // CollectionViewPagingExampleUITests 4 | // 5 | // Created by 진용호 on 2018. 7. 18.. 6 | // Copyright © 2018년 진용호. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class CollectionViewPagingExampleUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /CollectionViewPagingExampleUITests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CollectionViewPagingExample 2 | --------------------------------------------------------------------------------