├── .gitignore ├── DXScaleFlowLayout.podspec ├── DXScaleFlowLayout.xcodeproj └── project.pbxproj ├── DXScaleFlowLayout.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── Example ├── Example.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata └── Example │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── card_board_G1.imageset │ │ ├── Contents.json │ │ ├── card_board_G1@2x.png │ │ └── card_board_G1@3X.png │ ├── card_board_G2.imageset │ │ ├── Contents.json │ │ ├── card_board_G2@2x.png │ │ └── card_board_G2@3X.png │ ├── card_board_G3.imageset │ │ ├── Contents.json │ │ ├── card_board_G3@2x.png │ │ └── card_board_G3@3X.png │ ├── card_board_G4.imageset │ │ ├── Contents.json │ │ ├── card_board_G4@2x.png │ │ └── card_board_G4@3X.png │ └── card_board_G5.imageset │ │ ├── Contents.json │ │ ├── card_board_G5@2x.png │ │ └── card_board_G5@3X.png │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift ├── LICENSE ├── README.md ├── Resources └── scaleflowlayout.gif ├── Source ├── DXScaleFlowLayout.h └── DXScaleFlowLayout.swift └── Supporting Files └── Info.plist /.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 | # Package.resolved 41 | .build/ 42 | 43 | # CocoaPods 44 | # 45 | # We recommend against adding the Pods directory to your .gitignore. However 46 | # you should judge for yourself, the pros and cons are mentioned at: 47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 48 | # 49 | # Pods/ 50 | 51 | # Carthage 52 | # 53 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 54 | # Carthage/Checkouts 55 | 56 | Carthage/Build 57 | 58 | # fastlane 59 | # 60 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 61 | # screenshots whenever they are needed. 62 | # For more information about the recommended setup visit: 63 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 64 | 65 | fastlane/report.xml 66 | fastlane/Preview.html 67 | fastlane/screenshots/**/*.png 68 | fastlane/test_output 69 | -------------------------------------------------------------------------------- /DXScaleFlowLayout.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "DXScaleFlowLayout" 3 | s.version = "1.0.5" 4 | s.summary = "Custom collectionView layout that display scaled up/down cells" 5 | s.homepage = "https://github.com/SiriDx/DXScaleFlowLayout" 6 | s.license = { :type => "MIT" } 7 | s.authors = { "DeanChen" => "dxchen321@gmail.com" } 8 | s.requires_arc = true 9 | 10 | s.platform = :ios, '8.0' 11 | s.ios.deployment_target = "8.0" 12 | s.source = { :git => "https://github.com/SiriDx/DXScaleFlowLayout.git", :tag => s.version } 13 | s.source_files = "Source/*.swift" 14 | end 15 | -------------------------------------------------------------------------------- /DXScaleFlowLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 05FE959C2174A49900EACDDA /* DXScaleFlowLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 05FE959A2174A49900EACDDA /* DXScaleFlowLayout.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 05FE959F2174A4D700EACDDA /* DXScaleFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05FE959E2174A4D700EACDDA /* DXScaleFlowLayout.swift */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXFileReference section */ 15 | 05FE958E2174A44600EACDDA /* DXScaleFlowLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DXScaleFlowLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 16 | 05FE959A2174A49900EACDDA /* DXScaleFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DXScaleFlowLayout.h; sourceTree = ""; }; 17 | 05FE959E2174A4D700EACDDA /* DXScaleFlowLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DXScaleFlowLayout.swift; sourceTree = ""; }; 18 | 05FE95BF2174A63100EACDDA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 19 | /* End PBXFileReference section */ 20 | 21 | /* Begin PBXFrameworksBuildPhase section */ 22 | 05FE958A2174A44600EACDDA /* Frameworks */ = { 23 | isa = PBXFrameworksBuildPhase; 24 | buildActionMask = 2147483647; 25 | files = ( 26 | ); 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXFrameworksBuildPhase section */ 30 | 31 | /* Begin PBXGroup section */ 32 | 05FE95842174A44600EACDDA = { 33 | isa = PBXGroup; 34 | children = ( 35 | 05FE95992174A49900EACDDA /* Source */, 36 | 05FE95BE2174A63100EACDDA /* Supporting Files */, 37 | 05FE958F2174A44600EACDDA /* Products */, 38 | ); 39 | sourceTree = ""; 40 | }; 41 | 05FE958F2174A44600EACDDA /* Products */ = { 42 | isa = PBXGroup; 43 | children = ( 44 | 05FE958E2174A44600EACDDA /* DXScaleFlowLayout.framework */, 45 | ); 46 | name = Products; 47 | sourceTree = ""; 48 | }; 49 | 05FE95992174A49900EACDDA /* Source */ = { 50 | isa = PBXGroup; 51 | children = ( 52 | 05FE959E2174A4D700EACDDA /* DXScaleFlowLayout.swift */, 53 | 05FE959A2174A49900EACDDA /* DXScaleFlowLayout.h */, 54 | ); 55 | path = Source; 56 | sourceTree = ""; 57 | }; 58 | 05FE95BE2174A63100EACDDA /* Supporting Files */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 05FE95BF2174A63100EACDDA /* Info.plist */, 62 | ); 63 | path = "Supporting Files"; 64 | sourceTree = ""; 65 | }; 66 | /* End PBXGroup section */ 67 | 68 | /* Begin PBXHeadersBuildPhase section */ 69 | 05FE958B2174A44600EACDDA /* Headers */ = { 70 | isa = PBXHeadersBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | 05FE959C2174A49900EACDDA /* DXScaleFlowLayout.h in Headers */, 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | /* End PBXHeadersBuildPhase section */ 78 | 79 | /* Begin PBXNativeTarget section */ 80 | 05FE958D2174A44600EACDDA /* DXScaleFlowLayout */ = { 81 | isa = PBXNativeTarget; 82 | buildConfigurationList = 05FE95962174A44600EACDDA /* Build configuration list for PBXNativeTarget "DXScaleFlowLayout" */; 83 | buildPhases = ( 84 | 05FE95892174A44600EACDDA /* Sources */, 85 | 05FE958A2174A44600EACDDA /* Frameworks */, 86 | 05FE958B2174A44600EACDDA /* Headers */, 87 | 05FE958C2174A44600EACDDA /* Resources */, 88 | ); 89 | buildRules = ( 90 | ); 91 | dependencies = ( 92 | ); 93 | name = DXScaleFlowLayout; 94 | productName = DXScaleFlowLayout; 95 | productReference = 05FE958E2174A44600EACDDA /* DXScaleFlowLayout.framework */; 96 | productType = "com.apple.product-type.framework"; 97 | }; 98 | /* End PBXNativeTarget section */ 99 | 100 | /* Begin PBXProject section */ 101 | 05FE95852174A44600EACDDA /* Project object */ = { 102 | isa = PBXProject; 103 | attributes = { 104 | LastUpgradeCheck = 0930; 105 | ORGANIZATIONNAME = SiriDx; 106 | TargetAttributes = { 107 | 05FE958D2174A44600EACDDA = { 108 | CreatedOnToolsVersion = 9.3.1; 109 | LastSwiftMigration = 0930; 110 | }; 111 | }; 112 | }; 113 | buildConfigurationList = 05FE95882174A44600EACDDA /* Build configuration list for PBXProject "DXScaleFlowLayout" */; 114 | compatibilityVersion = "Xcode 9.3"; 115 | developmentRegion = en; 116 | hasScannedForEncodings = 0; 117 | knownRegions = ( 118 | en, 119 | Base, 120 | ); 121 | mainGroup = 05FE95842174A44600EACDDA; 122 | productRefGroup = 05FE958F2174A44600EACDDA /* Products */; 123 | projectDirPath = ""; 124 | projectRoot = ""; 125 | targets = ( 126 | 05FE958D2174A44600EACDDA /* DXScaleFlowLayout */, 127 | ); 128 | }; 129 | /* End PBXProject section */ 130 | 131 | /* Begin PBXResourcesBuildPhase section */ 132 | 05FE958C2174A44600EACDDA /* Resources */ = { 133 | isa = PBXResourcesBuildPhase; 134 | buildActionMask = 2147483647; 135 | files = ( 136 | ); 137 | runOnlyForDeploymentPostprocessing = 0; 138 | }; 139 | /* End PBXResourcesBuildPhase section */ 140 | 141 | /* Begin PBXSourcesBuildPhase section */ 142 | 05FE95892174A44600EACDDA /* Sources */ = { 143 | isa = PBXSourcesBuildPhase; 144 | buildActionMask = 2147483647; 145 | files = ( 146 | 05FE959F2174A4D700EACDDA /* DXScaleFlowLayout.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | 05FE95942174A44600EACDDA /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_ANALYZER_NONNULL = YES; 158 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 159 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 160 | CLANG_CXX_LIBRARY = "libc++"; 161 | CLANG_ENABLE_MODULES = YES; 162 | CLANG_ENABLE_OBJC_ARC = YES; 163 | CLANG_ENABLE_OBJC_WEAK = YES; 164 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 165 | CLANG_WARN_BOOL_CONVERSION = YES; 166 | CLANG_WARN_COMMA = YES; 167 | CLANG_WARN_CONSTANT_CONVERSION = YES; 168 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 169 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 170 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 171 | CLANG_WARN_EMPTY_BODY = YES; 172 | CLANG_WARN_ENUM_CONVERSION = YES; 173 | CLANG_WARN_INFINITE_RECURSION = YES; 174 | CLANG_WARN_INT_CONVERSION = YES; 175 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 177 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 180 | CLANG_WARN_STRICT_PROTOTYPES = YES; 181 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 182 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 183 | CLANG_WARN_UNREACHABLE_CODE = YES; 184 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 185 | CODE_SIGN_IDENTITY = "iPhone Developer"; 186 | COPY_PHASE_STRIP = NO; 187 | CURRENT_PROJECT_VERSION = 1; 188 | DEBUG_INFORMATION_FORMAT = dwarf; 189 | ENABLE_STRICT_OBJC_MSGSEND = YES; 190 | ENABLE_TESTABILITY = YES; 191 | GCC_C_LANGUAGE_STANDARD = gnu11; 192 | GCC_DYNAMIC_NO_PIC = NO; 193 | GCC_NO_COMMON_BLOCKS = YES; 194 | GCC_OPTIMIZATION_LEVEL = 0; 195 | GCC_PREPROCESSOR_DEFINITIONS = ( 196 | "DEBUG=1", 197 | "$(inherited)", 198 | ); 199 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 200 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 201 | GCC_WARN_UNDECLARED_SELECTOR = YES; 202 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 203 | GCC_WARN_UNUSED_FUNCTION = YES; 204 | GCC_WARN_UNUSED_VARIABLE = YES; 205 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 206 | MTL_ENABLE_DEBUG_INFO = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = iphoneos; 209 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 210 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 211 | VERSIONING_SYSTEM = "apple-generic"; 212 | VERSION_INFO_PREFIX = ""; 213 | }; 214 | name = Debug; 215 | }; 216 | 05FE95952174A44600EACDDA /* Release */ = { 217 | isa = XCBuildConfiguration; 218 | buildSettings = { 219 | ALWAYS_SEARCH_USER_PATHS = NO; 220 | CLANG_ANALYZER_NONNULL = YES; 221 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 222 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 223 | CLANG_CXX_LIBRARY = "libc++"; 224 | CLANG_ENABLE_MODULES = YES; 225 | CLANG_ENABLE_OBJC_ARC = YES; 226 | CLANG_ENABLE_OBJC_WEAK = YES; 227 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 228 | CLANG_WARN_BOOL_CONVERSION = YES; 229 | CLANG_WARN_COMMA = YES; 230 | CLANG_WARN_CONSTANT_CONVERSION = YES; 231 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 232 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 233 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 234 | CLANG_WARN_EMPTY_BODY = YES; 235 | CLANG_WARN_ENUM_CONVERSION = YES; 236 | CLANG_WARN_INFINITE_RECURSION = YES; 237 | CLANG_WARN_INT_CONVERSION = YES; 238 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 239 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 240 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 241 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 242 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 243 | CLANG_WARN_STRICT_PROTOTYPES = YES; 244 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 245 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 246 | CLANG_WARN_UNREACHABLE_CODE = YES; 247 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 248 | CODE_SIGN_IDENTITY = "iPhone Developer"; 249 | COPY_PHASE_STRIP = NO; 250 | CURRENT_PROJECT_VERSION = 1; 251 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 252 | ENABLE_NS_ASSERTIONS = NO; 253 | ENABLE_STRICT_OBJC_MSGSEND = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu11; 255 | GCC_NO_COMMON_BLOCKS = YES; 256 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 257 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 258 | GCC_WARN_UNDECLARED_SELECTOR = YES; 259 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 260 | GCC_WARN_UNUSED_FUNCTION = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 263 | MTL_ENABLE_DEBUG_INFO = NO; 264 | SDKROOT = iphoneos; 265 | SWIFT_COMPILATION_MODE = wholemodule; 266 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 267 | VALIDATE_PRODUCT = YES; 268 | VERSIONING_SYSTEM = "apple-generic"; 269 | VERSION_INFO_PREFIX = ""; 270 | }; 271 | name = Release; 272 | }; 273 | 05FE95972174A44600EACDDA /* Debug */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | CLANG_ENABLE_MODULES = YES; 277 | CODE_SIGN_IDENTITY = ""; 278 | CODE_SIGN_STYLE = Automatic; 279 | DEFINES_MODULE = YES; 280 | DYLIB_COMPATIBILITY_VERSION = 1; 281 | DYLIB_CURRENT_VERSION = 1; 282 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 283 | INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist"; 284 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 285 | LD_RUNPATH_SEARCH_PATHS = ( 286 | "$(inherited)", 287 | "@executable_path/Frameworks", 288 | "@loader_path/Frameworks", 289 | ); 290 | PRODUCT_BUNDLE_IDENTIFIER = com.siridx.DXScaleFlowLayout; 291 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 292 | SKIP_INSTALL = YES; 293 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 294 | SWIFT_VERSION = 4.0; 295 | TARGETED_DEVICE_FAMILY = "1,2"; 296 | }; 297 | name = Debug; 298 | }; 299 | 05FE95982174A44600EACDDA /* Release */ = { 300 | isa = XCBuildConfiguration; 301 | buildSettings = { 302 | CLANG_ENABLE_MODULES = YES; 303 | CODE_SIGN_IDENTITY = ""; 304 | CODE_SIGN_STYLE = Automatic; 305 | DEFINES_MODULE = YES; 306 | DYLIB_COMPATIBILITY_VERSION = 1; 307 | DYLIB_CURRENT_VERSION = 1; 308 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 309 | INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist"; 310 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 311 | LD_RUNPATH_SEARCH_PATHS = ( 312 | "$(inherited)", 313 | "@executable_path/Frameworks", 314 | "@loader_path/Frameworks", 315 | ); 316 | PRODUCT_BUNDLE_IDENTIFIER = com.siridx.DXScaleFlowLayout; 317 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 318 | SKIP_INSTALL = YES; 319 | SWIFT_VERSION = 4.0; 320 | TARGETED_DEVICE_FAMILY = "1,2"; 321 | }; 322 | name = Release; 323 | }; 324 | /* End XCBuildConfiguration section */ 325 | 326 | /* Begin XCConfigurationList section */ 327 | 05FE95882174A44600EACDDA /* Build configuration list for PBXProject "DXScaleFlowLayout" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | 05FE95942174A44600EACDDA /* Debug */, 331 | 05FE95952174A44600EACDDA /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | 05FE95962174A44600EACDDA /* Build configuration list for PBXNativeTarget "DXScaleFlowLayout" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 05FE95972174A44600EACDDA /* Debug */, 340 | 05FE95982174A44600EACDDA /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | /* End XCConfigurationList section */ 346 | }; 347 | rootObject = 05FE95852174A44600EACDDA /* Project object */; 348 | } 349 | -------------------------------------------------------------------------------- /DXScaleFlowLayout.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /DXScaleFlowLayout.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0556CF3A2174A746008388BF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0556CF392174A746008388BF /* AppDelegate.swift */; }; 11 | 0556CF3C2174A746008388BF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0556CF3B2174A746008388BF /* ViewController.swift */; }; 12 | 0556CF3F2174A746008388BF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0556CF3D2174A746008388BF /* Main.storyboard */; }; 13 | 0556CF412174A747008388BF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0556CF402174A747008388BF /* Assets.xcassets */; }; 14 | 0556CF442174A747008388BF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0556CF422174A747008388BF /* LaunchScreen.storyboard */; }; 15 | 0556CF722174A856008388BF /* DXScaleFlowLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0556CF712174A856008388BF /* DXScaleFlowLayout.framework */; }; 16 | 0556CF732174A856008388BF /* DXScaleFlowLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0556CF712174A856008388BF /* DXScaleFlowLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXCopyFilesBuildPhase section */ 20 | 0556CF742174A856008388BF /* Embed Frameworks */ = { 21 | isa = PBXCopyFilesBuildPhase; 22 | buildActionMask = 2147483647; 23 | dstPath = ""; 24 | dstSubfolderSpec = 10; 25 | files = ( 26 | 0556CF732174A856008388BF /* DXScaleFlowLayout.framework in Embed Frameworks */, 27 | ); 28 | name = "Embed Frameworks"; 29 | runOnlyForDeploymentPostprocessing = 0; 30 | }; 31 | /* End PBXCopyFilesBuildPhase section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 0556CF362174A746008388BF /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 0556CF392174A746008388BF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 36 | 0556CF3B2174A746008388BF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 37 | 0556CF3E2174A746008388BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 38 | 0556CF402174A747008388BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 39 | 0556CF432174A747008388BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 40 | 0556CF452174A747008388BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 41 | 0556CF712174A856008388BF /* DXScaleFlowLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = DXScaleFlowLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | /* End PBXFileReference section */ 43 | 44 | /* Begin PBXFrameworksBuildPhase section */ 45 | 0556CF332174A746008388BF /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | 0556CF722174A856008388BF /* DXScaleFlowLayout.framework in Frameworks */, 50 | ); 51 | runOnlyForDeploymentPostprocessing = 0; 52 | }; 53 | /* End PBXFrameworksBuildPhase section */ 54 | 55 | /* Begin PBXGroup section */ 56 | 0556CF2D2174A746008388BF = { 57 | isa = PBXGroup; 58 | children = ( 59 | 0556CF712174A856008388BF /* DXScaleFlowLayout.framework */, 60 | 0556CF382174A746008388BF /* Example */, 61 | 0556CF372174A746008388BF /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | 0556CF372174A746008388BF /* Products */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | 0556CF362174A746008388BF /* Example.app */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | 0556CF382174A746008388BF /* Example */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 0556CF392174A746008388BF /* AppDelegate.swift */, 77 | 0556CF3B2174A746008388BF /* ViewController.swift */, 78 | 0556CF3D2174A746008388BF /* Main.storyboard */, 79 | 0556CF402174A747008388BF /* Assets.xcassets */, 80 | 0556CF422174A747008388BF /* LaunchScreen.storyboard */, 81 | 0556CF452174A747008388BF /* Info.plist */, 82 | ); 83 | path = Example; 84 | sourceTree = ""; 85 | }; 86 | /* End PBXGroup section */ 87 | 88 | /* Begin PBXNativeTarget section */ 89 | 0556CF352174A746008388BF /* Example */ = { 90 | isa = PBXNativeTarget; 91 | buildConfigurationList = 0556CF482174A747008388BF /* Build configuration list for PBXNativeTarget "Example" */; 92 | buildPhases = ( 93 | 0556CF322174A746008388BF /* Sources */, 94 | 0556CF332174A746008388BF /* Frameworks */, 95 | 0556CF342174A746008388BF /* Resources */, 96 | 0556CF742174A856008388BF /* Embed Frameworks */, 97 | ); 98 | buildRules = ( 99 | ); 100 | dependencies = ( 101 | ); 102 | name = Example; 103 | productName = Example; 104 | productReference = 0556CF362174A746008388BF /* Example.app */; 105 | productType = "com.apple.product-type.application"; 106 | }; 107 | /* End PBXNativeTarget section */ 108 | 109 | /* Begin PBXProject section */ 110 | 0556CF2E2174A746008388BF /* Project object */ = { 111 | isa = PBXProject; 112 | attributes = { 113 | LastSwiftUpdateCheck = 0930; 114 | LastUpgradeCheck = 0930; 115 | ORGANIZATIONNAME = SiriDx; 116 | TargetAttributes = { 117 | 0556CF352174A746008388BF = { 118 | CreatedOnToolsVersion = 9.3.1; 119 | }; 120 | }; 121 | }; 122 | buildConfigurationList = 0556CF312174A746008388BF /* Build configuration list for PBXProject "Example" */; 123 | compatibilityVersion = "Xcode 9.3"; 124 | developmentRegion = en; 125 | hasScannedForEncodings = 0; 126 | knownRegions = ( 127 | en, 128 | Base, 129 | ); 130 | mainGroup = 0556CF2D2174A746008388BF; 131 | productRefGroup = 0556CF372174A746008388BF /* Products */; 132 | projectDirPath = ""; 133 | projectRoot = ""; 134 | targets = ( 135 | 0556CF352174A746008388BF /* Example */, 136 | ); 137 | }; 138 | /* End PBXProject section */ 139 | 140 | /* Begin PBXResourcesBuildPhase section */ 141 | 0556CF342174A746008388BF /* Resources */ = { 142 | isa = PBXResourcesBuildPhase; 143 | buildActionMask = 2147483647; 144 | files = ( 145 | 0556CF442174A747008388BF /* LaunchScreen.storyboard in Resources */, 146 | 0556CF412174A747008388BF /* Assets.xcassets in Resources */, 147 | 0556CF3F2174A746008388BF /* Main.storyboard in Resources */, 148 | ); 149 | runOnlyForDeploymentPostprocessing = 0; 150 | }; 151 | /* End PBXResourcesBuildPhase section */ 152 | 153 | /* Begin PBXSourcesBuildPhase section */ 154 | 0556CF322174A746008388BF /* Sources */ = { 155 | isa = PBXSourcesBuildPhase; 156 | buildActionMask = 2147483647; 157 | files = ( 158 | 0556CF3C2174A746008388BF /* ViewController.swift in Sources */, 159 | 0556CF3A2174A746008388BF /* AppDelegate.swift in Sources */, 160 | ); 161 | runOnlyForDeploymentPostprocessing = 0; 162 | }; 163 | /* End PBXSourcesBuildPhase section */ 164 | 165 | /* Begin PBXVariantGroup section */ 166 | 0556CF3D2174A746008388BF /* Main.storyboard */ = { 167 | isa = PBXVariantGroup; 168 | children = ( 169 | 0556CF3E2174A746008388BF /* Base */, 170 | ); 171 | name = Main.storyboard; 172 | sourceTree = ""; 173 | }; 174 | 0556CF422174A747008388BF /* LaunchScreen.storyboard */ = { 175 | isa = PBXVariantGroup; 176 | children = ( 177 | 0556CF432174A747008388BF /* Base */, 178 | ); 179 | name = LaunchScreen.storyboard; 180 | sourceTree = ""; 181 | }; 182 | /* End PBXVariantGroup section */ 183 | 184 | /* Begin XCBuildConfiguration section */ 185 | 0556CF462174A747008388BF /* Debug */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_ANALYZER_NONNULL = YES; 190 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_ENABLE_OBJC_WEAK = YES; 196 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 197 | CLANG_WARN_BOOL_CONVERSION = YES; 198 | CLANG_WARN_COMMA = YES; 199 | CLANG_WARN_CONSTANT_CONVERSION = YES; 200 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 202 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 203 | CLANG_WARN_EMPTY_BODY = YES; 204 | CLANG_WARN_ENUM_CONVERSION = YES; 205 | CLANG_WARN_INFINITE_RECURSION = YES; 206 | CLANG_WARN_INT_CONVERSION = YES; 207 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 209 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 211 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 212 | CLANG_WARN_STRICT_PROTOTYPES = YES; 213 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 214 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 215 | CLANG_WARN_UNREACHABLE_CODE = YES; 216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 217 | CODE_SIGN_IDENTITY = "iPhone Developer"; 218 | COPY_PHASE_STRIP = NO; 219 | DEBUG_INFORMATION_FORMAT = dwarf; 220 | ENABLE_STRICT_OBJC_MSGSEND = YES; 221 | ENABLE_TESTABILITY = YES; 222 | GCC_C_LANGUAGE_STANDARD = gnu11; 223 | GCC_DYNAMIC_NO_PIC = NO; 224 | GCC_NO_COMMON_BLOCKS = YES; 225 | GCC_OPTIMIZATION_LEVEL = 0; 226 | GCC_PREPROCESSOR_DEFINITIONS = ( 227 | "DEBUG=1", 228 | "$(inherited)", 229 | ); 230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 232 | GCC_WARN_UNDECLARED_SELECTOR = YES; 233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 234 | GCC_WARN_UNUSED_FUNCTION = YES; 235 | GCC_WARN_UNUSED_VARIABLE = YES; 236 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 237 | MTL_ENABLE_DEBUG_INFO = YES; 238 | ONLY_ACTIVE_ARCH = YES; 239 | SDKROOT = iphoneos; 240 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 241 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 242 | }; 243 | name = Debug; 244 | }; 245 | 0556CF472174A747008388BF /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | ALWAYS_SEARCH_USER_PATHS = NO; 249 | CLANG_ANALYZER_NONNULL = YES; 250 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 251 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 252 | CLANG_CXX_LIBRARY = "libc++"; 253 | CLANG_ENABLE_MODULES = YES; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_ENABLE_OBJC_WEAK = YES; 256 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_COMMA = YES; 259 | CLANG_WARN_CONSTANT_CONVERSION = YES; 260 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 261 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 262 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 263 | CLANG_WARN_EMPTY_BODY = YES; 264 | CLANG_WARN_ENUM_CONVERSION = YES; 265 | CLANG_WARN_INFINITE_RECURSION = YES; 266 | CLANG_WARN_INT_CONVERSION = YES; 267 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 268 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 269 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 270 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 272 | CLANG_WARN_STRICT_PROTOTYPES = YES; 273 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 274 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 275 | CLANG_WARN_UNREACHABLE_CODE = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | CODE_SIGN_IDENTITY = "iPhone Developer"; 278 | COPY_PHASE_STRIP = NO; 279 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 280 | ENABLE_NS_ASSERTIONS = NO; 281 | ENABLE_STRICT_OBJC_MSGSEND = YES; 282 | GCC_C_LANGUAGE_STANDARD = gnu11; 283 | GCC_NO_COMMON_BLOCKS = YES; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 291 | MTL_ENABLE_DEBUG_INFO = NO; 292 | SDKROOT = iphoneos; 293 | SWIFT_COMPILATION_MODE = wholemodule; 294 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 295 | VALIDATE_PRODUCT = YES; 296 | }; 297 | name = Release; 298 | }; 299 | 0556CF492174A747008388BF /* Debug */ = { 300 | isa = XCBuildConfiguration; 301 | buildSettings = { 302 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 303 | CODE_SIGN_STYLE = Automatic; 304 | INFOPLIST_FILE = Example/Info.plist; 305 | LD_RUNPATH_SEARCH_PATHS = ( 306 | "$(inherited)", 307 | "@executable_path/Frameworks", 308 | ); 309 | PRODUCT_BUNDLE_IDENTIFIER = com.siridx.Example; 310 | PRODUCT_NAME = "$(TARGET_NAME)"; 311 | SWIFT_VERSION = 4.0; 312 | TARGETED_DEVICE_FAMILY = "1,2"; 313 | }; 314 | name = Debug; 315 | }; 316 | 0556CF4A2174A747008388BF /* Release */ = { 317 | isa = XCBuildConfiguration; 318 | buildSettings = { 319 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 320 | CODE_SIGN_STYLE = Automatic; 321 | INFOPLIST_FILE = Example/Info.plist; 322 | LD_RUNPATH_SEARCH_PATHS = ( 323 | "$(inherited)", 324 | "@executable_path/Frameworks", 325 | ); 326 | PRODUCT_BUNDLE_IDENTIFIER = com.siridx.Example; 327 | PRODUCT_NAME = "$(TARGET_NAME)"; 328 | SWIFT_VERSION = 4.0; 329 | TARGETED_DEVICE_FAMILY = "1,2"; 330 | }; 331 | name = Release; 332 | }; 333 | /* End XCBuildConfiguration section */ 334 | 335 | /* Begin XCConfigurationList section */ 336 | 0556CF312174A746008388BF /* Build configuration list for PBXProject "Example" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | 0556CF462174A747008388BF /* Debug */, 340 | 0556CF472174A747008388BF /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | 0556CF482174A747008388BF /* Build configuration list for PBXNativeTarget "Example" */ = { 346 | isa = XCConfigurationList; 347 | buildConfigurations = ( 348 | 0556CF492174A747008388BF /* Debug */, 349 | 0556CF4A2174A747008388BF /* Release */, 350 | ); 351 | defaultConfigurationIsVisible = 0; 352 | defaultConfigurationName = Release; 353 | }; 354 | /* End XCConfigurationList section */ 355 | }; 356 | rootObject = 0556CF2E2174A746008388BF /* Project object */; 357 | } 358 | -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Example 4 | // 5 | // Created by Dean on 2018/10/15. 6 | // Copyright © 2018年 SiriDx. 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 | -------------------------------------------------------------------------------- /Example/Example/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 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "card_board_G1@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "card_board_G1@3X.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G1.imageset/card_board_G1@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G1.imageset/card_board_G1@2x.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G1.imageset/card_board_G1@3X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G1.imageset/card_board_G1@3X.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "card_board_G2@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "card_board_G2@3X.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G2.imageset/card_board_G2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G2.imageset/card_board_G2@2x.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G2.imageset/card_board_G2@3X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G2.imageset/card_board_G2@3X.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "card_board_G3@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "card_board_G3@3X.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G3.imageset/card_board_G3@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G3.imageset/card_board_G3@2x.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G3.imageset/card_board_G3@3X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G3.imageset/card_board_G3@3X.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "card_board_G4@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "card_board_G4@3X.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G4.imageset/card_board_G4@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G4.imageset/card_board_G4@2x.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G4.imageset/card_board_G4@3X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G4.imageset/card_board_G4@3X.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G5.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "filename" : "card_board_G5@2x.png", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "filename" : "card_board_G5@3X.png", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G5.imageset/card_board_G5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G5.imageset/card_board_G5@2x.png -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/card_board_G5.imageset/card_board_G5@3X.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Example/Example/Assets.xcassets/card_board_G5.imageset/card_board_G5@3X.png -------------------------------------------------------------------------------- /Example/Example/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 | -------------------------------------------------------------------------------- /Example/Example/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 | -------------------------------------------------------------------------------- /Example/Example/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 | -------------------------------------------------------------------------------- /Example/Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Example 4 | // 5 | // Created by Dean on 2018/10/15. 6 | // Copyright © 2018年 SiriDx. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import UIKit 12 | import DXScaleFlowLayout 13 | 14 | class ViewController: UIViewController { 15 | 16 | private var collectionView:UICollectionView! 17 | private var scaleLayout:DXScaleFlowLayout! 18 | 19 | private lazy var datas:[String] = { 20 | var images = [String]() 21 | for i in 1...5 { 22 | images.append("card_board_G\(i)") 23 | } 24 | return images 25 | }() 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | view.backgroundColor = UIColor.white 31 | 32 | setupLayout() 33 | setupCollectionView() 34 | 35 | } 36 | 37 | func setupLayout() { 38 | let layout = DXScaleFlowLayout() 39 | self.scaleLayout = layout 40 | layout.isPagingEnabled = true 41 | layout.transformScale = (300 - 250) / 300.0 42 | layout.minimumLineSpacing = -120 43 | layout.minimumAlpha = 0.8 44 | 45 | let itemW:CGFloat = 570 * 0.5 + 20 46 | let itemH:CGFloat = (388.0 / 706.0) * itemW 47 | layout.itemSize = CGSize(width: itemW, height: itemH) 48 | } 49 | 50 | func setupCollectionView() { 51 | 52 | let kScreenW = UIScreen.main.bounds.size.width 53 | let kScreenH = UIScreen.main.bounds.size.height 54 | 55 | let clvH:CGFloat = 170.0 56 | let clvY = (kScreenH - clvH) * 0.5 57 | let rect = CGRect(x: 0, y: clvY, width: kScreenW, height: clvH) 58 | 59 | let collectionView = UICollectionView(frame: rect, collectionViewLayout: scaleLayout) 60 | self.collectionView = collectionView 61 | collectionView.showsHorizontalScrollIndicator = false 62 | 63 | self.collectionView = collectionView 64 | view.addSubview(collectionView) 65 | collectionView.backgroundColor = UIColor.white 66 | 67 | collectionView.dataSource = self 68 | collectionView.delegate = self 69 | 70 | collectionView.register(ExampleCell.self, forCellWithReuseIdentifier: "cell") 71 | } 72 | 73 | } 74 | 75 | extension ViewController:UICollectionViewDelegate, UICollectionViewDataSource { 76 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 77 | return datas.count 78 | } 79 | 80 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 81 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! ExampleCell 82 | cell.bgImageView.image = UIImage.init(named: datas[indexPath.row]) 83 | return cell 84 | } 85 | } 86 | 87 | class ExampleCell: UICollectionViewCell { 88 | 89 | var bgImageView:UIImageView! 90 | 91 | override init(frame: CGRect) { 92 | super.init(frame: frame) 93 | let bgImageView = UIImageView() 94 | contentView.addSubview(bgImageView) 95 | self.bgImageView = bgImageView 96 | } 97 | 98 | override func layoutSubviews() { 99 | super.layoutSubviews() 100 | bgImageView.frame = bounds 101 | } 102 | 103 | required init?(coder aDecoder: NSCoder) { 104 | fatalError("init(coder:) has not been implemented") 105 | } 106 | 107 | } 108 | 109 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Dean Chen 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 | # DXScaleFlowLayout 2 | 3 | ![CocoaPods](https://img.shields.io/cocoapods/v/DXScaleFlowLayout.svg) 4 | ![Platform](https://img.shields.io/badge/platforms-iOS%208.0+-333333.svg) 5 | ![Swift](https://img.shields.io/badge/Swift-4.2-orange.svg) 6 | 7 | DXScaleFlowLayout is a subclass of the UICollectionViewFlowLayout allowing the display of scale up/down cells in a UICollectionView. 8 | 9 | ![Demo](https://github.com/SiriDx/DXScaleFlowLayout/blob/master/Resources/scaleflowlayout.gif) 10 | 11 | 1. [Requirements](#requirements) 12 | 2. [Integration](#integration) 13 | 3. [Usage](#usage) 14 | - [Basics](#basics) 15 | - [Property](#property) 16 | 17 | ## Requirements 18 | 19 | - iOS 9.0+ 20 | - Xcode 8 21 | 22 | ## Integration 23 | 24 | #### CocoaPods (iOS 8+) 25 | 26 | You can use [CocoaPods](http://cocoapods.org/) to install `DXScaleFlowLayout` by adding it to your `Podfile`: 27 | 28 | ```ruby 29 | platform :ios, '8.0' 30 | use_frameworks! 31 | 32 | target 'MyApp' do 33 | pod 'DXScaleFlowLayout', '~> 1.0.0' 34 | end 35 | ``` 36 | 37 | #### Manually (iOS 7+) 38 | 39 | To use this library in your project manually, you may drag DXScaleFlowLayout.swift to the project tree 40 | 41 | ## Usage 42 | 43 | #### Basics 44 | 45 | Import DXScaleFlowLayout module 46 | 47 | ```swift 48 | import DXScaleFlowLayout 49 | ``` 50 | 51 | Create an instance of DXScaleFlowLayout with transform scale you need to initialize your UICollectionView 52 | 53 | ```swift 54 | let scaleLayout = DXScaleFlowLayout() 55 | scaleLayout.transformScale = 0.15 56 | 57 | UICollectionView(frame: .zero, collectionViewLayout: scaleLayout) 58 | ``` 59 | 60 | #### Property 61 | 62 | - **transformScale**: 63 | 64 | ```swift 65 | open var transformScale: CGFloat 66 | ``` 67 | 68 | - **minimumAlpha**: 69 | 70 | ```swift 71 | open var minimumAlpha: CGFloat 72 | ``` 73 | 74 | - **isPagingEnabled**: 75 | 76 | ```swift 77 | open var isPagingEnabled: Bool 78 | ``` 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /Resources/scaleflowlayout.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SiriDx/DXScaleFlowLayout/ba914b2125fd12af1eba9b46d39b8ae15d2a9bba/Resources/scaleflowlayout.gif -------------------------------------------------------------------------------- /Source/DXScaleFlowLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // DXScaleFlowLayout.h 3 | // DXScaleFlowLayout 4 | // 5 | // Created by Dean on 2018/10/15. 6 | // Copyright © 2018年 SiriDx. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for DXScaleFlowLayout. 12 | FOUNDATION_EXPORT double DXScaleFlowLayoutVersionNumber; 13 | 14 | //! Project version string for DXScaleFlowLayout. 15 | FOUNDATION_EXPORT const unsigned char DXScaleFlowLayoutVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Source/DXScaleFlowLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DXScaleFlowLayout.swift 3 | // DXScaleFlowLayout 4 | // 5 | // Created by Dean on 2018/10/15. 6 | // Copyright © 2018年 SiriDx. All rights reserved. 7 | // 代码地址: https://github.com/SiriDx/DXScaleFlowLayout 8 | 9 | import UIKit 10 | 11 | /* 12 | extension UICollectionView { 13 | 14 | open func scaleScroll(toIndex index:Int, animated:Bool = false) { 15 | 16 | if index < 0 || index > numberOfItems(inSection: 0) - 1 { 17 | return 18 | } 19 | 20 | guard let scaleLayout = collectionViewLayout as? DXScaleFlowLayout else { return } 21 | 22 | DispatchQueue.main.async { 23 | let totalDis = scaleLayout.itemSize.width + scaleLayout.minimumLineSpacing 24 | let newOffsetX = totalDis * CGFloat(index) - self.contentInset.left 25 | self.setContentOffset(CGPoint(x: newOffsetX, y: self.contentOffset.y), animated: animated) 26 | self.layoutIfNeeded() 27 | } 28 | } 29 | 30 | } 31 | */ 32 | 33 | open class DXScaleFlowLayout: UICollectionViewFlowLayout { 34 | 35 | open var isPagingEnabled: Bool = true 36 | open var transformScale: CGFloat = 1 37 | open var minimumAlpha: CGFloat = 1 38 | 39 | private var isFirstLayout:Bool = true 40 | 41 | override open func prepare() { 42 | super.prepare() 43 | if isFirstLayout { 44 | resetLayout() 45 | isFirstLayout = false 46 | } 47 | } 48 | 49 | private func resetLayout() { 50 | 51 | if minimumAlpha > 1 || minimumAlpha < 0 { 52 | minimumAlpha = 1 53 | } 54 | 55 | scrollDirection = .horizontal 56 | minimumInteritemSpacing = 0 57 | 58 | if let collectionView = self.collectionView { 59 | let clvW = collectionView.frame.size.width 60 | let insetLeftRight = (clvW - itemSize.width) * 0.5 61 | var inset = collectionView.contentInset 62 | inset.left = insetLeftRight 63 | inset.right = insetLeftRight 64 | collectionView.contentInset = inset 65 | 66 | if isPagingEnabled { 67 | collectionView.decelerationRate = UIScrollViewDecelerationRateFast 68 | } 69 | 70 | let offsetW = itemSize.width * transformScale * 0.5 71 | let newSpacing = minimumLineSpacing - offsetW 72 | 73 | minimumLineSpacing = newSpacing 74 | } 75 | } 76 | 77 | override open func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 78 | 79 | if let attributes = super.layoutAttributesForElements(in: rect), 80 | let collectionView = self.collectionView { 81 | 82 | let visibleRect = CGRect(x: collectionView.contentOffset.x, y: collectionView.contentOffset.y, width: collectionView.frame.size.width, height: collectionView.frame.size.height) 83 | 84 | guard let copyAttributes = NSArray.init(array: attributes, copyItems: true) as? [UICollectionViewLayoutAttributes] else { return nil } 85 | 86 | let newAttributes = copyAttributes.map { (attribute) -> UICollectionViewLayoutAttributes in 87 | 88 | attribute.transform = CGAffineTransform.init(scaleX: transformScale, y: transformScale) 89 | 90 | if visibleRect.intersects(attribute.frame) { 91 | 92 | let contentOffsetX = collectionView.contentOffset.x 93 | let collectionViewCenterX = collectionView.bounds.size.width * 0.5 94 | 95 | let centerX = attribute.center.x 96 | let distance = abs(centerX - contentOffsetX - collectionViewCenterX) 97 | 98 | let totalDistance = itemSize.width + minimumLineSpacing 99 | 100 | let ratio:CGFloat = transformScale 101 | 102 | let newW = itemSize.width - itemSize.width * ratio 103 | let offsetW = abs((totalDistance - distance) / totalDistance * (newW - itemSize.width)) 104 | 105 | let scale = (newW + offsetW) / itemSize.width 106 | 107 | attribute.alpha = minimumAlpha + ((1 - minimumAlpha) / totalDistance) * (totalDistance - distance) 108 | 109 | attribute.transform = CGAffineTransform.init(scaleX: scale, y: scale) 110 | attribute.zIndex = Int(scale * 10) 111 | } 112 | 113 | return attribute 114 | } 115 | 116 | return newAttributes 117 | } 118 | return nil 119 | } 120 | 121 | override open func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { 122 | return true 123 | } 124 | 125 | override open func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { 126 | 127 | if isPagingEnabled == false { 128 | return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) 129 | } 130 | 131 | if let collectionView = self.collectionView { 132 | 133 | let lastRect = CGRect(x: proposedContentOffset.x, y: proposedContentOffset.y, width: collectionView.frame.size.width, height: collectionView.frame.size.height) 134 | 135 | let centerX = proposedContentOffset.x + collectionView.frame.size.width * 0.5; 136 | 137 | if let attributes = self.layoutAttributesForElements(in: lastRect) { 138 | 139 | var adjustOffsetX = CGFloat(MAXFLOAT); 140 | for att in attributes { 141 | let offsetX = abs(att.center.x - centerX) 142 | if offsetX < abs(adjustOffsetX) { 143 | adjustOffsetX = att.center.x - centerX; 144 | } 145 | } 146 | 147 | var newProposedContentOffsetX = proposedContentOffset.x + adjustOffsetX 148 | 149 | let maxOffsetX = collectionView.contentSize.width - collectionView.frame.size.width + collectionView.contentInset.left 150 | 151 | if newProposedContentOffsetX > maxOffsetX { 152 | newProposedContentOffsetX = maxOffsetX 153 | } 154 | 155 | return CGPoint(x: newProposedContentOffsetX, y: proposedContentOffset.y) 156 | } 157 | } 158 | 159 | return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | --------------------------------------------------------------------------------