├── .gitignore ├── ASHSpringyCollectionView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── ash.xcuserdatad │ └── xcschemes │ ├── ASHSpringyCollectionView.xcscheme │ └── xcschememanagement.plist ├── ASHSpringyCollectionView ├── ASHAppDelegate.h ├── ASHAppDelegate.m ├── ASHCollectionViewController.h ├── ASHCollectionViewController.m ├── ASHSpringyCollectionView-Info.plist ├── ASHSpringyCollectionView-Prefix.pch ├── ASHSpringyCollectionViewFlowLayout.h ├── ASHSpringyCollectionViewFlowLayout.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── en.lproj │ └── InfoPlist.strings └── main.m ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5EB0A31117B965C400708DD3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EB0A31017B965C400708DD3 /* Foundation.framework */; }; 11 | 5EB0A31317B965C400708DD3 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EB0A31217B965C400708DD3 /* CoreGraphics.framework */; }; 12 | 5EB0A31517B965C400708DD3 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5EB0A31417B965C400708DD3 /* UIKit.framework */; }; 13 | 5EB0A31B17B965C400708DD3 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5EB0A31917B965C400708DD3 /* InfoPlist.strings */; }; 14 | 5EB0A31D17B965C400708DD3 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB0A31C17B965C400708DD3 /* main.m */; }; 15 | 5EB0A32117B965C400708DD3 /* ASHAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB0A32017B965C400708DD3 /* ASHAppDelegate.m */; }; 16 | 5EB0A32317B965C400708DD3 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5EB0A32217B965C400708DD3 /* Images.xcassets */; }; 17 | 5EB0A34117B9663900708DD3 /* ASHSpringyCollectionViewFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB0A34017B9663900708DD3 /* ASHSpringyCollectionViewFlowLayout.m */; }; 18 | 5EB0A34417B9664D00708DD3 /* ASHCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB0A34317B9664D00708DD3 /* ASHCollectionViewController.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 5EB0A30D17B965C400708DD3 /* ASHSpringyCollectionView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ASHSpringyCollectionView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | 5EB0A31017B965C400708DD3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 24 | 5EB0A31217B965C400708DD3 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 25 | 5EB0A31417B965C400708DD3 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 26 | 5EB0A31817B965C400708DD3 /* ASHSpringyCollectionView-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "ASHSpringyCollectionView-Info.plist"; sourceTree = ""; }; 27 | 5EB0A31A17B965C400708DD3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 28 | 5EB0A31C17B965C400708DD3 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29 | 5EB0A31E17B965C400708DD3 /* ASHSpringyCollectionView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ASHSpringyCollectionView-Prefix.pch"; sourceTree = ""; }; 30 | 5EB0A31F17B965C400708DD3 /* ASHAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASHAppDelegate.h; sourceTree = ""; }; 31 | 5EB0A32017B965C400708DD3 /* ASHAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASHAppDelegate.m; sourceTree = ""; }; 32 | 5EB0A32217B965C400708DD3 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 33 | 5EB0A32917B965C500708DD3 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 34 | 5EB0A33F17B9663900708DD3 /* ASHSpringyCollectionViewFlowLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASHSpringyCollectionViewFlowLayout.h; sourceTree = ""; }; 35 | 5EB0A34017B9663900708DD3 /* ASHSpringyCollectionViewFlowLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASHSpringyCollectionViewFlowLayout.m; sourceTree = ""; }; 36 | 5EB0A34217B9664D00708DD3 /* ASHCollectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASHCollectionViewController.h; sourceTree = ""; }; 37 | 5EB0A34317B9664D00708DD3 /* ASHCollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASHCollectionViewController.m; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 5EB0A30A17B965C400708DD3 /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | 5EB0A31317B965C400708DD3 /* CoreGraphics.framework in Frameworks */, 46 | 5EB0A31517B965C400708DD3 /* UIKit.framework in Frameworks */, 47 | 5EB0A31117B965C400708DD3 /* Foundation.framework in Frameworks */, 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | /* End PBXFrameworksBuildPhase section */ 52 | 53 | /* Begin PBXGroup section */ 54 | 5EB0A30417B965C400708DD3 = { 55 | isa = PBXGroup; 56 | children = ( 57 | 5EB0A31617B965C400708DD3 /* ASHSpringyCollectionView */, 58 | 5EB0A30F17B965C400708DD3 /* Frameworks */, 59 | 5EB0A30E17B965C400708DD3 /* Products */, 60 | ); 61 | sourceTree = ""; 62 | }; 63 | 5EB0A30E17B965C400708DD3 /* Products */ = { 64 | isa = PBXGroup; 65 | children = ( 66 | 5EB0A30D17B965C400708DD3 /* ASHSpringyCollectionView.app */, 67 | ); 68 | name = Products; 69 | sourceTree = ""; 70 | }; 71 | 5EB0A30F17B965C400708DD3 /* Frameworks */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | 5EB0A31017B965C400708DD3 /* Foundation.framework */, 75 | 5EB0A31217B965C400708DD3 /* CoreGraphics.framework */, 76 | 5EB0A31417B965C400708DD3 /* UIKit.framework */, 77 | 5EB0A32917B965C500708DD3 /* XCTest.framework */, 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | 5EB0A31617B965C400708DD3 /* ASHSpringyCollectionView */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 5EB0A31F17B965C400708DD3 /* ASHAppDelegate.h */, 86 | 5EB0A32017B965C400708DD3 /* ASHAppDelegate.m */, 87 | 5EB0A34217B9664D00708DD3 /* ASHCollectionViewController.h */, 88 | 5EB0A34317B9664D00708DD3 /* ASHCollectionViewController.m */, 89 | 5EB0A33F17B9663900708DD3 /* ASHSpringyCollectionViewFlowLayout.h */, 90 | 5EB0A34017B9663900708DD3 /* ASHSpringyCollectionViewFlowLayout.m */, 91 | 5EB0A32217B965C400708DD3 /* Images.xcassets */, 92 | 5EB0A31717B965C400708DD3 /* Supporting Files */, 93 | ); 94 | path = ASHSpringyCollectionView; 95 | sourceTree = ""; 96 | }; 97 | 5EB0A31717B965C400708DD3 /* Supporting Files */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 5EB0A31817B965C400708DD3 /* ASHSpringyCollectionView-Info.plist */, 101 | 5EB0A31917B965C400708DD3 /* InfoPlist.strings */, 102 | 5EB0A31C17B965C400708DD3 /* main.m */, 103 | 5EB0A31E17B965C400708DD3 /* ASHSpringyCollectionView-Prefix.pch */, 104 | ); 105 | name = "Supporting Files"; 106 | sourceTree = ""; 107 | }; 108 | /* End PBXGroup section */ 109 | 110 | /* Begin PBXNativeTarget section */ 111 | 5EB0A30C17B965C400708DD3 /* ASHSpringyCollectionView */ = { 112 | isa = PBXNativeTarget; 113 | buildConfigurationList = 5EB0A33917B965C500708DD3 /* Build configuration list for PBXNativeTarget "ASHSpringyCollectionView" */; 114 | buildPhases = ( 115 | 5EB0A30917B965C400708DD3 /* Sources */, 116 | 5EB0A30A17B965C400708DD3 /* Frameworks */, 117 | 5EB0A30B17B965C400708DD3 /* Resources */, 118 | ); 119 | buildRules = ( 120 | ); 121 | dependencies = ( 122 | ); 123 | name = ASHSpringyCollectionView; 124 | productName = ASHSpringyCollectionView; 125 | productReference = 5EB0A30D17B965C400708DD3 /* ASHSpringyCollectionView.app */; 126 | productType = "com.apple.product-type.application"; 127 | }; 128 | /* End PBXNativeTarget section */ 129 | 130 | /* Begin PBXProject section */ 131 | 5EB0A30517B965C400708DD3 /* Project object */ = { 132 | isa = PBXProject; 133 | attributes = { 134 | CLASSPREFIX = ASH; 135 | LastUpgradeCheck = 0500; 136 | ORGANIZATIONNAME = "Ash Furrow"; 137 | }; 138 | buildConfigurationList = 5EB0A30817B965C400708DD3 /* Build configuration list for PBXProject "ASHSpringyCollectionView" */; 139 | compatibilityVersion = "Xcode 3.2"; 140 | developmentRegion = English; 141 | hasScannedForEncodings = 0; 142 | knownRegions = ( 143 | en, 144 | ); 145 | mainGroup = 5EB0A30417B965C400708DD3; 146 | productRefGroup = 5EB0A30E17B965C400708DD3 /* Products */; 147 | projectDirPath = ""; 148 | projectRoot = ""; 149 | targets = ( 150 | 5EB0A30C17B965C400708DD3 /* ASHSpringyCollectionView */, 151 | ); 152 | }; 153 | /* End PBXProject section */ 154 | 155 | /* Begin PBXResourcesBuildPhase section */ 156 | 5EB0A30B17B965C400708DD3 /* Resources */ = { 157 | isa = PBXResourcesBuildPhase; 158 | buildActionMask = 2147483647; 159 | files = ( 160 | 5EB0A31B17B965C400708DD3 /* InfoPlist.strings in Resources */, 161 | 5EB0A32317B965C400708DD3 /* Images.xcassets in Resources */, 162 | ); 163 | runOnlyForDeploymentPostprocessing = 0; 164 | }; 165 | /* End PBXResourcesBuildPhase section */ 166 | 167 | /* Begin PBXSourcesBuildPhase section */ 168 | 5EB0A30917B965C400708DD3 /* Sources */ = { 169 | isa = PBXSourcesBuildPhase; 170 | buildActionMask = 2147483647; 171 | files = ( 172 | 5EB0A31D17B965C400708DD3 /* main.m in Sources */, 173 | 5EB0A32117B965C400708DD3 /* ASHAppDelegate.m in Sources */, 174 | 5EB0A34117B9663900708DD3 /* ASHSpringyCollectionViewFlowLayout.m in Sources */, 175 | 5EB0A34417B9664D00708DD3 /* ASHCollectionViewController.m in Sources */, 176 | ); 177 | runOnlyForDeploymentPostprocessing = 0; 178 | }; 179 | /* End PBXSourcesBuildPhase section */ 180 | 181 | /* Begin PBXVariantGroup section */ 182 | 5EB0A31917B965C400708DD3 /* InfoPlist.strings */ = { 183 | isa = PBXVariantGroup; 184 | children = ( 185 | 5EB0A31A17B965C400708DD3 /* en */, 186 | ); 187 | name = InfoPlist.strings; 188 | sourceTree = ""; 189 | }; 190 | /* End PBXVariantGroup section */ 191 | 192 | /* Begin XCBuildConfiguration section */ 193 | 5EB0A33717B965C500708DD3 /* Debug */ = { 194 | isa = XCBuildConfiguration; 195 | buildSettings = { 196 | ALWAYS_SEARCH_USER_PATHS = NO; 197 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 198 | CLANG_CXX_LIBRARY = "libc++"; 199 | CLANG_ENABLE_MODULES = YES; 200 | CLANG_ENABLE_OBJC_ARC = YES; 201 | CLANG_WARN_BOOL_CONVERSION = YES; 202 | CLANG_WARN_CONSTANT_CONVERSION = YES; 203 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 204 | CLANG_WARN_EMPTY_BODY = YES; 205 | CLANG_WARN_ENUM_CONVERSION = YES; 206 | CLANG_WARN_INT_CONVERSION = YES; 207 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 208 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 209 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 210 | COPY_PHASE_STRIP = NO; 211 | GCC_C_LANGUAGE_STANDARD = gnu99; 212 | GCC_DYNAMIC_NO_PIC = NO; 213 | GCC_OPTIMIZATION_LEVEL = 0; 214 | GCC_PREPROCESSOR_DEFINITIONS = ( 215 | "DEBUG=1", 216 | "$(inherited)", 217 | ); 218 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 219 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 220 | GCC_WARN_UNDECLARED_SELECTOR = YES; 221 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 222 | GCC_WARN_UNUSED_FUNCTION = YES; 223 | GCC_WARN_UNUSED_VARIABLE = YES; 224 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 225 | ONLY_ACTIVE_ARCH = YES; 226 | SDKROOT = iphoneos; 227 | }; 228 | name = Debug; 229 | }; 230 | 5EB0A33817B965C500708DD3 /* Release */ = { 231 | isa = XCBuildConfiguration; 232 | buildSettings = { 233 | ALWAYS_SEARCH_USER_PATHS = NO; 234 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 235 | CLANG_CXX_LIBRARY = "libc++"; 236 | CLANG_ENABLE_MODULES = YES; 237 | CLANG_ENABLE_OBJC_ARC = YES; 238 | CLANG_WARN_BOOL_CONVERSION = YES; 239 | CLANG_WARN_CONSTANT_CONVERSION = YES; 240 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 241 | CLANG_WARN_EMPTY_BODY = YES; 242 | CLANG_WARN_ENUM_CONVERSION = YES; 243 | CLANG_WARN_INT_CONVERSION = YES; 244 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 247 | COPY_PHASE_STRIP = YES; 248 | ENABLE_NS_ASSERTIONS = NO; 249 | GCC_C_LANGUAGE_STANDARD = gnu99; 250 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 251 | GCC_WARN_UNDECLARED_SELECTOR = YES; 252 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 253 | GCC_WARN_UNUSED_FUNCTION = YES; 254 | GCC_WARN_UNUSED_VARIABLE = YES; 255 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 256 | SDKROOT = iphoneos; 257 | VALIDATE_PRODUCT = YES; 258 | }; 259 | name = Release; 260 | }; 261 | 5EB0A33A17B965C500708DD3 /* Debug */ = { 262 | isa = XCBuildConfiguration; 263 | buildSettings = { 264 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 265 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 266 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 267 | GCC_PREFIX_HEADER = "ASHSpringyCollectionView/ASHSpringyCollectionView-Prefix.pch"; 268 | INFOPLIST_FILE = "ASHSpringyCollectionView/ASHSpringyCollectionView-Info.plist"; 269 | PRODUCT_NAME = "$(TARGET_NAME)"; 270 | WRAPPER_EXTENSION = app; 271 | }; 272 | name = Debug; 273 | }; 274 | 5EB0A33B17B965C500708DD3 /* Release */ = { 275 | isa = XCBuildConfiguration; 276 | buildSettings = { 277 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 278 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 279 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 280 | GCC_PREFIX_HEADER = "ASHSpringyCollectionView/ASHSpringyCollectionView-Prefix.pch"; 281 | INFOPLIST_FILE = "ASHSpringyCollectionView/ASHSpringyCollectionView-Info.plist"; 282 | PRODUCT_NAME = "$(TARGET_NAME)"; 283 | WRAPPER_EXTENSION = app; 284 | }; 285 | name = Release; 286 | }; 287 | /* End XCBuildConfiguration section */ 288 | 289 | /* Begin XCConfigurationList section */ 290 | 5EB0A30817B965C400708DD3 /* Build configuration list for PBXProject "ASHSpringyCollectionView" */ = { 291 | isa = XCConfigurationList; 292 | buildConfigurations = ( 293 | 5EB0A33717B965C500708DD3 /* Debug */, 294 | 5EB0A33817B965C500708DD3 /* Release */, 295 | ); 296 | defaultConfigurationIsVisible = 0; 297 | defaultConfigurationName = Release; 298 | }; 299 | 5EB0A33917B965C500708DD3 /* Build configuration list for PBXNativeTarget "ASHSpringyCollectionView" */ = { 300 | isa = XCConfigurationList; 301 | buildConfigurations = ( 302 | 5EB0A33A17B965C500708DD3 /* Debug */, 303 | 5EB0A33B17B965C500708DD3 /* Release */, 304 | ); 305 | defaultConfigurationIsVisible = 0; 306 | }; 307 | /* End XCConfigurationList section */ 308 | }; 309 | rootObject = 5EB0A30517B965C400708DD3 /* Project object */; 310 | } 311 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView.xcodeproj/xcuserdata/ash.xcuserdatad/xcschemes/ASHSpringyCollectionView.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView.xcodeproj/xcuserdata/ash.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ASHSpringyCollectionView.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 5EB0A30C17B965C400708DD3 16 | 17 | primary 18 | 19 | 20 | 5EB0A32717B965C500708DD3 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASHAppDelegate.h 3 | // ASHSpringyCollectionView 4 | // 5 | // Created by Ash Furrow on 2013-08-12. 6 | // Copyright (c) 2013 Ash Furrow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ASHAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ASHAppDelegate.m 3 | // ASHSpringyCollectionView 4 | // 5 | // Created by Ash Furrow on 2013-08-12. 6 | // Copyright (c) 2013 Ash Furrow. All rights reserved. 7 | // 8 | 9 | #import "ASHAppDelegate.h" 10 | #import "ASHCollectionViewController.h" 11 | #import "ASHSpringyCollectionViewFlowLayout.h" 12 | 13 | @implementation ASHAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | self.window.backgroundColor = [UIColor whiteColor]; 19 | self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ASHCollectionViewController alloc] initWithCollectionViewLayout:[[ASHSpringyCollectionViewFlowLayout alloc] init]]]; 20 | [self.window makeKeyAndVisible]; 21 | return YES; 22 | } 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application 25 | { 26 | // 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. 27 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 28 | } 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application 31 | { 32 | // 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. 33 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | } 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application 37 | { 38 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application 42 | { 43 | // 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. 44 | } 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application 47 | { 48 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHCollectionViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASHCollectionViewController.h 3 | // ASHSpringyCollectionView 4 | // 5 | // Created by Ash Furrow on 2013-08-12. 6 | // Copyright (c) 2013 Ash Furrow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ASHCollectionViewController : UICollectionViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHCollectionViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ASHCollectionViewController.m 3 | // ASHSpringyCollectionView 4 | // 5 | // Created by Ash Furrow on 2013-08-12. 6 | // Copyright (c) 2013 Ash Furrow. All rights reserved. 7 | // 8 | 9 | #import "ASHCollectionViewController.h" 10 | 11 | @interface ASHCollectionViewController () 12 | 13 | @end 14 | 15 | @implementation ASHCollectionViewController 16 | 17 | static NSString *CellIdentifier = @"Cell"; 18 | 19 | - (void)viewDidLoad 20 | { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view. 23 | 24 | [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:CellIdentifier]; 25 | self.collectionView.backgroundColor = [UIColor whiteColor]; 26 | } 27 | 28 | #pragma mark - UICollectionViewDataSource Methods 29 | 30 | -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 31 | return 10000; 32 | } 33 | 34 | -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 35 | UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; 36 | 37 | cell.backgroundColor = [UIColor orangeColor]; 38 | 39 | return cell; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHSpringyCollectionView-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.ashfurrow.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHSpringyCollectionView-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHSpringyCollectionViewFlowLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // ASHSpringyCollectionViewFlowLayout.h 3 | // ASHSpringyCollectionView 4 | // 5 | // Created by Ash Furrow on 2013-08-12. 6 | // Copyright (c) 2013 Ash Furrow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ASHSpringyCollectionViewFlowLayout : UICollectionViewFlowLayout 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/ASHSpringyCollectionViewFlowLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // ASHSpringyCollectionViewFlowLayout.m 3 | // ASHSpringyCollectionView 4 | // 5 | // Created by Ash Furrow on 2013-08-12. 6 | // Copyright (c) 2013 Ash Furrow. All rights reserved. 7 | // 8 | 9 | /* 10 | 11 | This implementation is based on https://github.com/TeehanLax/UICollectionView-Spring-Demo 12 | which I developed at Teehan+Lax. Check it out. 13 | 14 | */ 15 | 16 | #import "ASHSpringyCollectionViewFlowLayout.h" 17 | 18 | @interface ASHSpringyCollectionViewFlowLayout () 19 | 20 | @property (nonatomic, strong) UIDynamicAnimator *dynamicAnimator; 21 | 22 | @property (nonatomic, strong) NSMutableSet *visibleIndexPathsSet; 23 | @property (nonatomic, assign) CGFloat latestDelta; 24 | 25 | @end 26 | 27 | @implementation ASHSpringyCollectionViewFlowLayout 28 | 29 | -(id)init { 30 | if (!(self = [super init])) return nil; 31 | 32 | self.minimumInteritemSpacing = 10; 33 | self.minimumLineSpacing = 10; 34 | self.itemSize = CGSizeMake(44, 44); 35 | self.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10); 36 | 37 | self.dynamicAnimator = [[UIDynamicAnimator alloc] initWithCollectionViewLayout:self]; 38 | self.visibleIndexPathsSet = [NSMutableSet set]; 39 | 40 | return self; 41 | } 42 | 43 | -(void)prepareLayout { 44 | [super prepareLayout]; 45 | 46 | // Need to overflow our actual visible rect slightly to avoid flickering. 47 | CGRect visibleRect = CGRectInset((CGRect){.origin = self.collectionView.bounds.origin, .size = self.collectionView.frame.size}, -100, -100); 48 | 49 | NSArray *itemsInVisibleRectArray = [super layoutAttributesForElementsInRect:visibleRect]; 50 | 51 | NSSet *itemsIndexPathsInVisibleRectSet = [NSSet setWithArray:[itemsInVisibleRectArray valueForKey:@"indexPath"]]; 52 | 53 | // Step 1: Remove any behaviours that are no longer visible. 54 | NSArray *noLongerVisibleBehaviours = [self.dynamicAnimator.behaviors filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(UIAttachmentBehavior *behaviour, NSDictionary *bindings) { 55 | BOOL currentlyVisible = [itemsIndexPathsInVisibleRectSet member:[[[behaviour items] firstObject] indexPath]] != nil; 56 | return !currentlyVisible; 57 | }]]; 58 | 59 | [noLongerVisibleBehaviours enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { 60 | [self.dynamicAnimator removeBehavior:obj]; 61 | [self.visibleIndexPathsSet removeObject:[[[obj items] firstObject] indexPath]]; 62 | }]; 63 | 64 | // Step 2: Add any newly visible behaviours. 65 | // A "newly visible" item is one that is in the itemsInVisibleRect(Set|Array) but not in the visibleIndexPathsSet 66 | NSArray *newlyVisibleItems = [itemsInVisibleRectArray filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(UICollectionViewLayoutAttributes *item, NSDictionary *bindings) { 67 | BOOL currentlyVisible = [self.visibleIndexPathsSet member:item.indexPath] != nil; 68 | return !currentlyVisible; 69 | }]]; 70 | 71 | CGPoint touchLocation = [self.collectionView.panGestureRecognizer locationInView:self.collectionView]; 72 | 73 | [newlyVisibleItems enumerateObjectsUsingBlock:^(UICollectionViewLayoutAttributes *item, NSUInteger idx, BOOL *stop) { 74 | CGPoint center = item.center; 75 | UIAttachmentBehavior *springBehaviour = [[UIAttachmentBehavior alloc] initWithItem:item attachedToAnchor:center]; 76 | 77 | springBehaviour.length = 0.0f; 78 | springBehaviour.damping = 0.8f; 79 | springBehaviour.frequency = 1.0f; 80 | 81 | // If our touchLocation is not (0,0), we'll need to adjust our item's center "in flight" 82 | if (!CGPointEqualToPoint(CGPointZero, touchLocation)) { 83 | CGFloat yDistanceFromTouch = fabsf(touchLocation.y - springBehaviour.anchorPoint.y); 84 | CGFloat xDistanceFromTouch = fabsf(touchLocation.x - springBehaviour.anchorPoint.x); 85 | CGFloat scrollResistance = (yDistanceFromTouch + xDistanceFromTouch) / 1500.0f; 86 | 87 | if (self.latestDelta < 0) { 88 | center.y += MAX(self.latestDelta, self.latestDelta*scrollResistance); 89 | } 90 | else { 91 | center.y += MIN(self.latestDelta, self.latestDelta*scrollResistance); 92 | } 93 | item.center = center; 94 | } 95 | 96 | [self.dynamicAnimator addBehavior:springBehaviour]; 97 | [self.visibleIndexPathsSet addObject:item.indexPath]; 98 | }]; 99 | } 100 | 101 | -(NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { 102 | return [self.dynamicAnimator itemsInRect:rect]; 103 | } 104 | 105 | -(UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath { 106 | return [self.dynamicAnimator layoutAttributesForCellAtIndexPath:indexPath]; 107 | } 108 | 109 | -(BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { 110 | UIScrollView *scrollView = self.collectionView; 111 | CGFloat delta = newBounds.origin.y - scrollView.bounds.origin.y; 112 | 113 | self.latestDelta = delta; 114 | 115 | CGPoint touchLocation = [self.collectionView.panGestureRecognizer locationInView:self.collectionView]; 116 | 117 | [self.dynamicAnimator.behaviors enumerateObjectsUsingBlock:^(UIAttachmentBehavior *springBehaviour, NSUInteger idx, BOOL *stop) { 118 | CGFloat yDistanceFromTouch = fabsf(touchLocation.y - springBehaviour.anchorPoint.y); 119 | CGFloat xDistanceFromTouch = fabsf(touchLocation.x - springBehaviour.anchorPoint.x); 120 | CGFloat scrollResistance = (yDistanceFromTouch + xDistanceFromTouch) / 1500.0f; 121 | 122 | UICollectionViewLayoutAttributes *item = [springBehaviour.items firstObject]; 123 | CGPoint center = item.center; 124 | if (delta < 0) { 125 | center.y += MAX(delta, delta*scrollResistance); 126 | } 127 | else { 128 | center.y += MIN(delta, delta*scrollResistance); 129 | } 130 | item.center = center; 131 | 132 | [self.dynamicAnimator updateItemUsingCurrentState:item]; 133 | }]; 134 | 135 | return NO; 136 | } 137 | 138 | @end 139 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ASHSpringyCollectionView/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /ASHSpringyCollectionView/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /ASHSpringyCollectionView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ASHSpringyCollectionView 4 | // 5 | // Created by Ash Furrow on 2013-08-12. 6 | // Copyright (c) 2013 Ash Furrow. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "ASHAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([ASHAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Ash Furrow 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ASHSpringyCollectionView 2 | ======================== 3 | 4 | This is an example of how to use UIKit Dynamics with UICollectionViews while employing a tiling system for efficiency even when scrolling through thousands of items. 5 | 6 | ![Example](http://f.cl.ly/items/411o450x2E3A3c3m2b3k/springyCollectionView.gif) 7 | --------------------------------------------------------------------------------