├── .gitignore ├── PXParallaxViewController.xcodeproj ├── project.pbxproj └── xcuserdata │ └── paddy.xcuserdatad │ └── xcschemes │ └── PXParallaxViewControllerDemo.xcscheme ├── PXParallaxViewController ├── PXAppDelegate.h ├── PXAppDelegate.m ├── PXParallaxViewController-Info.plist ├── PXParallaxViewController-Prefix.pch ├── PXParallaxViewController.h ├── PXParallaxViewController.m ├── en.lproj │ └── InfoPlist.strings └── main.m ├── README.md ├── shovel.png ├── shovel@2x.png └── testContentView.xib /.gitignore: -------------------------------------------------------------------------------- 1 | PXParallaxViewController.xcodeproj/project.xcworkspace/contents.xcworkspacedata 2 | PXParallaxViewController.xcodeproj/project.xcworkspace/xcuserdata/paddy.xcuserdatad/UserInterfaceState.xcuserstate 3 | PXParallaxViewController.xcodeproj/project.xcworkspace/xcuserdata/paddy.xcuserdatad/WorkspaceSettings.xcsettings 4 | PXParallaxViewController.xcodeproj/xcuserdata/paddy.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist 5 | PXParallaxViewController.xcodeproj/xcuserdata/paddy.xcuserdatad/xcschemes/PXParallaxViewController.xcscheme 6 | PXParallaxViewController.xcodeproj/xcuserdata/paddy.xcuserdatad/xcschemes/xcschememanagement.plist 7 | -------------------------------------------------------------------------------- /PXParallaxViewController.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 036FB47615DACE6F009C5E5C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 036FB47515DACE6F009C5E5C /* UIKit.framework */; }; 11 | 036FB47815DACE6F009C5E5C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 036FB47715DACE6F009C5E5C /* Foundation.framework */; }; 12 | 036FB47A15DACE6F009C5E5C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 036FB47915DACE6F009C5E5C /* CoreGraphics.framework */; }; 13 | 036FB48015DACE6F009C5E5C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 036FB47E15DACE6F009C5E5C /* InfoPlist.strings */; }; 14 | 036FB48215DACE6F009C5E5C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 036FB48115DACE6F009C5E5C /* main.m */; }; 15 | 036FB48615DACE6F009C5E5C /* PXAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 036FB48515DACE6F009C5E5C /* PXAppDelegate.m */; }; 16 | 036FB49115DAD251009C5E5C /* shovel.png in Resources */ = {isa = PBXBuildFile; fileRef = 036FB48F15DAD251009C5E5C /* shovel.png */; }; 17 | 036FB49215DAD251009C5E5C /* shovel@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 036FB49015DAD251009C5E5C /* shovel@2x.png */; }; 18 | 036FB49415DAD366009C5E5C /* testContentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 036FB49315DAD366009C5E5C /* testContentView.xib */; }; 19 | 036FB49515DAD455009C5E5C /* PXParallaxViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 036FB48D15DACEA4009C5E5C /* PXParallaxViewController.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 036FB47115DACE6F009C5E5C /* PXParallaxViewController.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PXParallaxViewController.app; sourceTree = BUILT_PRODUCTS_DIR; }; 24 | 036FB47515DACE6F009C5E5C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 25 | 036FB47715DACE6F009C5E5C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 26 | 036FB47915DACE6F009C5E5C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 27 | 036FB47D15DACE6F009C5E5C /* PXParallaxViewController-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PXParallaxViewController-Info.plist"; sourceTree = ""; }; 28 | 036FB47F15DACE6F009C5E5C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 29 | 036FB48115DACE6F009C5E5C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 30 | 036FB48315DACE6F009C5E5C /* PXParallaxViewController-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PXParallaxViewController-Prefix.pch"; sourceTree = ""; }; 31 | 036FB48415DACE6F009C5E5C /* PXAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PXAppDelegate.h; path = PXParallaxViewController/PXAppDelegate.h; sourceTree = ""; }; 32 | 036FB48515DACE6F009C5E5C /* PXAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PXAppDelegate.m; path = PXParallaxViewController/PXAppDelegate.m; sourceTree = ""; }; 33 | 036FB48C15DACEA4009C5E5C /* PXParallaxViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PXParallaxViewController.h; sourceTree = ""; }; 34 | 036FB48D15DACEA4009C5E5C /* PXParallaxViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PXParallaxViewController.m; sourceTree = ""; }; 35 | 036FB48F15DAD251009C5E5C /* shovel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = shovel.png; sourceTree = ""; }; 36 | 036FB49015DAD251009C5E5C /* shovel@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "shovel@2x.png"; sourceTree = ""; }; 37 | 036FB49315DAD366009C5E5C /* testContentView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = testContentView.xib; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 036FB46E15DACE6F009C5E5C /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | 036FB47615DACE6F009C5E5C /* UIKit.framework in Frameworks */, 46 | 036FB47815DACE6F009C5E5C /* Foundation.framework in Frameworks */, 47 | 036FB47A15DACE6F009C5E5C /* CoreGraphics.framework in Frameworks */, 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | /* End PBXFrameworksBuildPhase section */ 52 | 53 | /* Begin PBXGroup section */ 54 | 036FB46615DACE6F009C5E5C = { 55 | isa = PBXGroup; 56 | children = ( 57 | 036FB48E15DACEAB009C5E5C /* PXParallaxDemo */, 58 | 036FB47B15DACE6F009C5E5C /* PXParallaxViewController */, 59 | 036FB47415DACE6F009C5E5C /* Frameworks */, 60 | 036FB47215DACE6F009C5E5C /* Products */, 61 | ); 62 | sourceTree = ""; 63 | }; 64 | 036FB47215DACE6F009C5E5C /* Products */ = { 65 | isa = PBXGroup; 66 | children = ( 67 | 036FB47115DACE6F009C5E5C /* PXParallaxViewController.app */, 68 | ); 69 | name = Products; 70 | sourceTree = ""; 71 | }; 72 | 036FB47415DACE6F009C5E5C /* Frameworks */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | 036FB47515DACE6F009C5E5C /* UIKit.framework */, 76 | 036FB47715DACE6F009C5E5C /* Foundation.framework */, 77 | 036FB47915DACE6F009C5E5C /* CoreGraphics.framework */, 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | 036FB47B15DACE6F009C5E5C /* PXParallaxViewController */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 036FB48C15DACEA4009C5E5C /* PXParallaxViewController.h */, 86 | 036FB48D15DACEA4009C5E5C /* PXParallaxViewController.m */, 87 | ); 88 | path = PXParallaxViewController; 89 | sourceTree = ""; 90 | }; 91 | 036FB47C15DACE6F009C5E5C /* Supporting Files */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | 036FB47D15DACE6F009C5E5C /* PXParallaxViewController-Info.plist */, 95 | 036FB47E15DACE6F009C5E5C /* InfoPlist.strings */, 96 | 036FB48115DACE6F009C5E5C /* main.m */, 97 | 036FB48315DACE6F009C5E5C /* PXParallaxViewController-Prefix.pch */, 98 | ); 99 | name = "Supporting Files"; 100 | path = PXParallaxViewController; 101 | sourceTree = ""; 102 | }; 103 | 036FB48E15DACEAB009C5E5C /* PXParallaxDemo */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 036FB47C15DACE6F009C5E5C /* Supporting Files */, 107 | 036FB48F15DAD251009C5E5C /* shovel.png */, 108 | 036FB49015DAD251009C5E5C /* shovel@2x.png */, 109 | 036FB48415DACE6F009C5E5C /* PXAppDelegate.h */, 110 | 036FB48515DACE6F009C5E5C /* PXAppDelegate.m */, 111 | 036FB49315DAD366009C5E5C /* testContentView.xib */, 112 | ); 113 | name = PXParallaxDemo; 114 | sourceTree = ""; 115 | }; 116 | /* End PBXGroup section */ 117 | 118 | /* Begin PBXNativeTarget section */ 119 | 036FB47015DACE6F009C5E5C /* PXParallaxViewController */ = { 120 | isa = PBXNativeTarget; 121 | buildConfigurationList = 036FB48915DACE6F009C5E5C /* Build configuration list for PBXNativeTarget "PXParallaxViewController" */; 122 | buildPhases = ( 123 | 036FB46D15DACE6F009C5E5C /* Sources */, 124 | 036FB46E15DACE6F009C5E5C /* Frameworks */, 125 | 036FB46F15DACE6F009C5E5C /* Resources */, 126 | ); 127 | buildRules = ( 128 | ); 129 | dependencies = ( 130 | ); 131 | name = PXParallaxViewController; 132 | productName = PXParallaxViewController; 133 | productReference = 036FB47115DACE6F009C5E5C /* PXParallaxViewController.app */; 134 | productType = "com.apple.product-type.application"; 135 | }; 136 | /* End PBXNativeTarget section */ 137 | 138 | /* Begin PBXProject section */ 139 | 036FB46815DACE6F009C5E5C /* Project object */ = { 140 | isa = PBXProject; 141 | attributes = { 142 | CLASSPREFIX = PX; 143 | LastUpgradeCheck = 0440; 144 | ORGANIZATIONNAME = 500px; 145 | }; 146 | buildConfigurationList = 036FB46B15DACE6F009C5E5C /* Build configuration list for PBXProject "PXParallaxViewController" */; 147 | compatibilityVersion = "Xcode 3.2"; 148 | developmentRegion = English; 149 | hasScannedForEncodings = 0; 150 | knownRegions = ( 151 | en, 152 | ); 153 | mainGroup = 036FB46615DACE6F009C5E5C; 154 | productRefGroup = 036FB47215DACE6F009C5E5C /* Products */; 155 | projectDirPath = ""; 156 | projectRoot = ""; 157 | targets = ( 158 | 036FB47015DACE6F009C5E5C /* PXParallaxViewController */, 159 | ); 160 | }; 161 | /* End PBXProject section */ 162 | 163 | /* Begin PBXResourcesBuildPhase section */ 164 | 036FB46F15DACE6F009C5E5C /* Resources */ = { 165 | isa = PBXResourcesBuildPhase; 166 | buildActionMask = 2147483647; 167 | files = ( 168 | 036FB48015DACE6F009C5E5C /* InfoPlist.strings in Resources */, 169 | 036FB49115DAD251009C5E5C /* shovel.png in Resources */, 170 | 036FB49215DAD251009C5E5C /* shovel@2x.png in Resources */, 171 | 036FB49415DAD366009C5E5C /* testContentView.xib in Resources */, 172 | ); 173 | runOnlyForDeploymentPostprocessing = 0; 174 | }; 175 | /* End PBXResourcesBuildPhase section */ 176 | 177 | /* Begin PBXSourcesBuildPhase section */ 178 | 036FB46D15DACE6F009C5E5C /* Sources */ = { 179 | isa = PBXSourcesBuildPhase; 180 | buildActionMask = 2147483647; 181 | files = ( 182 | 036FB49515DAD455009C5E5C /* PXParallaxViewController.m in Sources */, 183 | 036FB48215DACE6F009C5E5C /* main.m in Sources */, 184 | 036FB48615DACE6F009C5E5C /* PXAppDelegate.m in Sources */, 185 | ); 186 | runOnlyForDeploymentPostprocessing = 0; 187 | }; 188 | /* End PBXSourcesBuildPhase section */ 189 | 190 | /* Begin PBXVariantGroup section */ 191 | 036FB47E15DACE6F009C5E5C /* InfoPlist.strings */ = { 192 | isa = PBXVariantGroup; 193 | children = ( 194 | 036FB47F15DACE6F009C5E5C /* en */, 195 | ); 196 | name = InfoPlist.strings; 197 | sourceTree = ""; 198 | }; 199 | /* End PBXVariantGroup section */ 200 | 201 | /* Begin XCBuildConfiguration section */ 202 | 036FB48715DACE6F009C5E5C /* Debug */ = { 203 | isa = XCBuildConfiguration; 204 | buildSettings = { 205 | ALWAYS_SEARCH_USER_PATHS = NO; 206 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 207 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 208 | CLANG_ENABLE_OBJC_ARC = YES; 209 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 210 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 211 | COPY_PHASE_STRIP = NO; 212 | GCC_C_LANGUAGE_STANDARD = gnu99; 213 | GCC_DYNAMIC_NO_PIC = NO; 214 | GCC_OPTIMIZATION_LEVEL = 0; 215 | GCC_PREPROCESSOR_DEFINITIONS = ( 216 | "DEBUG=1", 217 | "$(inherited)", 218 | ); 219 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 220 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 221 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 223 | GCC_WARN_UNUSED_VARIABLE = YES; 224 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 225 | SDKROOT = iphoneos; 226 | }; 227 | name = Debug; 228 | }; 229 | 036FB48815DACE6F009C5E5C /* Release */ = { 230 | isa = XCBuildConfiguration; 231 | buildSettings = { 232 | ALWAYS_SEARCH_USER_PATHS = NO; 233 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 234 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 235 | CLANG_ENABLE_OBJC_ARC = YES; 236 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 237 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 238 | COPY_PHASE_STRIP = YES; 239 | GCC_C_LANGUAGE_STANDARD = gnu99; 240 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 241 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 242 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 243 | GCC_WARN_UNUSED_VARIABLE = YES; 244 | IPHONEOS_DEPLOYMENT_TARGET = 5.1; 245 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 246 | SDKROOT = iphoneos; 247 | VALIDATE_PRODUCT = YES; 248 | }; 249 | name = Release; 250 | }; 251 | 036FB48A15DACE6F009C5E5C /* Debug */ = { 252 | isa = XCBuildConfiguration; 253 | buildSettings = { 254 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 255 | GCC_PREFIX_HEADER = "PXParallaxViewController/PXParallaxViewController-Prefix.pch"; 256 | INFOPLIST_FILE = "PXParallaxViewController/PXParallaxViewController-Info.plist"; 257 | PRODUCT_NAME = "$(TARGET_NAME)"; 258 | WRAPPER_EXTENSION = app; 259 | }; 260 | name = Debug; 261 | }; 262 | 036FB48B15DACE6F009C5E5C /* Release */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 266 | GCC_PREFIX_HEADER = "PXParallaxViewController/PXParallaxViewController-Prefix.pch"; 267 | INFOPLIST_FILE = "PXParallaxViewController/PXParallaxViewController-Info.plist"; 268 | PRODUCT_NAME = "$(TARGET_NAME)"; 269 | WRAPPER_EXTENSION = app; 270 | }; 271 | name = Release; 272 | }; 273 | /* End XCBuildConfiguration section */ 274 | 275 | /* Begin XCConfigurationList section */ 276 | 036FB46B15DACE6F009C5E5C /* Build configuration list for PBXProject "PXParallaxViewController" */ = { 277 | isa = XCConfigurationList; 278 | buildConfigurations = ( 279 | 036FB48715DACE6F009C5E5C /* Debug */, 280 | 036FB48815DACE6F009C5E5C /* Release */, 281 | ); 282 | defaultConfigurationIsVisible = 0; 283 | defaultConfigurationName = Release; 284 | }; 285 | 036FB48915DACE6F009C5E5C /* Build configuration list for PBXNativeTarget "PXParallaxViewController" */ = { 286 | isa = XCConfigurationList; 287 | buildConfigurations = ( 288 | 036FB48A15DACE6F009C5E5C /* Debug */, 289 | 036FB48B15DACE6F009C5E5C /* Release */, 290 | ); 291 | defaultConfigurationIsVisible = 0; 292 | }; 293 | /* End XCConfigurationList section */ 294 | }; 295 | rootObject = 036FB46815DACE6F009C5E5C /* Project object */; 296 | } 297 | -------------------------------------------------------------------------------- /PXParallaxViewController.xcodeproj/xcuserdata/paddy.xcuserdatad/xcschemes/PXParallaxViewControllerDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /PXParallaxViewController/PXAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // PXAppDelegate.h 3 | // PXParallaxViewController 4 | // 5 | // Created by Paddy O'Brien on 2012-08-14. 6 | // Copyright (c) 2012 500px. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PXAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PXParallaxViewController/PXAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // PXAppDelegate.m 3 | // PXParallaxViewController 4 | // 5 | // Created by Paddy O'Brien on 2012-08-14. 6 | // Copyright (c) 2012 500px. All rights reserved. 7 | // 8 | 9 | #import "PXAppDelegate.h" 10 | #import "PXParallaxViewController.h" 11 | 12 | @implementation PXAppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | self.window.backgroundColor = [UIColor whiteColor]; 18 | [self.window makeKeyAndVisible]; 19 | 20 | UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shovel"]]; 21 | imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 22 | imageView.contentMode = UIViewContentModeScaleAspectFill; 23 | 24 | UIView *testContentView = [[[UINib nibWithNibName:@"testContentView" bundle:nil] instantiateWithOwner:nil options:nil] objectAtIndex:0]; 25 | 26 | PXParallaxViewController *paralaxViewController = [[PXParallaxViewController alloc] initWithContentView:testContentView andParallaxView:imageView]; 27 | paralaxViewController.parallaxHeight = 150; 28 | paralaxViewController.contentScrollView.delegate = self; 29 | _window.rootViewController = paralaxViewController; 30 | 31 | return YES; 32 | } 33 | 34 | /** 35 | * tests to make sure delegate methods are forwarded properly. 36 | */ 37 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 38 | { 39 | NSLog(@"%s was forwarded", __PRETTY_FUNCTION__); 40 | } 41 | 42 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView 43 | { 44 | NSLog(@"%s was forwarded", __PRETTY_FUNCTION__); 45 | } 46 | 47 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 48 | { 49 | NSLog(@"%s was forwarded", __PRETTY_FUNCTION__); 50 | } 51 | @end 52 | -------------------------------------------------------------------------------- /PXParallaxViewController/PXParallaxViewController-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.500px.${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 | -------------------------------------------------------------------------------- /PXParallaxViewController/PXParallaxViewController-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PXParallaxViewController' target in the 'PXParallaxViewController' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /PXParallaxViewController/PXParallaxViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PXParallaxViewController.h 3 | // 4 | // Created by Paddy O'Brien on 14/08/2012. 5 | // Copyright (c) 2012 500px Inc. All rights reserved. 6 | // 7 | // Adapted from RBParallaxTableViewController by Rheese Burgess 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 10 | // this software and associated documentation files (the "Software"), to deal in 11 | // the Software without restriction, including without limitation the rights to 12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 13 | // of the Software, and to permit persons to whom the Software is furnished to do 14 | // so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | // 27 | 28 | 29 | @interface PXParallaxViewController : UIViewController 30 | /** 31 | * The scrollview that contains the content 32 | */ 33 | @property (nonatomic, readonly) UIScrollView *contentScrollView; 34 | 35 | /** 36 | * The scrollview that contains the parallax View 37 | */ 38 | @property (nonatomic, readonly) UIScrollView *parallaxScrollView; 39 | 40 | /** 41 | * The view to be shown with the parallax effect 42 | */ 43 | @property (nonatomic, strong) UIView *parallaxView; 44 | 45 | /** 46 | * The content view that obscures the parallax view 47 | */ 48 | @property (nonatomic, strong) UIView *contentView; 49 | 50 | /** 51 | * The visible height of the parallax view at rest 52 | */ 53 | @property (nonatomic, assign) CGFloat parallaxHeight; 54 | 55 | - (id)initWithContentView:(UIView *)contentView andParallaxView:(UIView *)parallaxView; 56 | @end 57 | -------------------------------------------------------------------------------- /PXParallaxViewController/PXParallaxViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PXParallaxViewController.m 3 | // 4 | // Created by Paddy O'Brien on 14/08/2012. 5 | // Copyright (c) 2012 500px Inc. All rights reserved. 6 | // 7 | // Adapted from RBParallaxTableViewController by Rheese Burgess 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 10 | // this software and associated documentation files (the "Software"), to deal in 11 | // the Software without restriction, including without limitation the rights to 12 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 13 | // of the Software, and to permit persons to whom the Software is furnished to do 14 | // so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | // 27 | 28 | #import "PXParallaxViewController.h" 29 | 30 | #define DEFAULT_PARALLAX_HEIGHT 200.0f 31 | 32 | @interface PXParallaxViewController () 33 | @property (nonatomic, weak) id contentDelegate; 34 | @end 35 | 36 | @implementation PXParallaxViewController 37 | 38 | static CGFloat ImageHeight = 300.0; 39 | 40 | - (id)initWithContentView:(UIView *)contentView andParallaxView:(UIView *)parallaxView 41 | { 42 | self = [super initWithNibName:nil bundle:nil]; 43 | if (self) 44 | { 45 | _parallaxHeight = DEFAULT_PARALLAX_HEIGHT; 46 | 47 | _parallaxScrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; 48 | _parallaxScrollView.backgroundColor = [UIColor clearColor]; 49 | _parallaxScrollView.showsHorizontalScrollIndicator = NO; 50 | _parallaxScrollView.showsVerticalScrollIndicator = NO; 51 | 52 | _contentScrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; 53 | _contentScrollView.backgroundColor = [UIColor clearColor]; 54 | _contentScrollView.delegate = self; 55 | 56 | [self.view addSubview:_parallaxScrollView]; 57 | self.parallaxView = parallaxView; 58 | 59 | [self.view addSubview:_contentScrollView]; 60 | self.contentView = contentView; 61 | 62 | [_contentScrollView addObserver:self forKeyPath:@"delegate" options:NSKeyValueObservingOptionNew context:nil]; 63 | } 64 | 65 | return self; 66 | } 67 | 68 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context 69 | { 70 | if (object == _contentScrollView && [keyPath isEqualToString:@"delegate"]) 71 | { 72 | id secondaryDelegate = [change valueForKey:NSKeyValueChangeNewKey]; 73 | if (secondaryDelegate != self) 74 | { 75 | _contentDelegate = secondaryDelegate; 76 | _contentScrollView.delegate = self; 77 | } 78 | } 79 | } 80 | 81 | 82 | - (void)setContentView:(UIView *)contentView 83 | { 84 | _contentView = contentView; 85 | _contentView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; 86 | 87 | [_contentScrollView addSubview:_contentView]; 88 | } 89 | 90 | - (void)setParallaxView:(UIView *)parallaxView 91 | { 92 | _parallaxView = parallaxView; 93 | _parallaxView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; 94 | 95 | [_parallaxScrollView addSubview:_parallaxView]; 96 | } 97 | 98 | #pragma mark - Parallax effect 99 | 100 | - (void)updateOffsets 101 | { 102 | CGFloat yOffset = _contentScrollView.contentOffset.y; 103 | CGFloat threshold = ImageHeight - _parallaxHeight; 104 | 105 | if (yOffset > -threshold && yOffset < 0) 106 | { 107 | _parallaxScrollView.contentOffset = CGPointMake(0.0, floorf(yOffset / 2.0)); 108 | } 109 | else if (yOffset < 0) 110 | { 111 | _parallaxScrollView.contentOffset = CGPointMake(0.0, yOffset + floorf(threshold / 2.0)); 112 | } 113 | else 114 | { 115 | _parallaxScrollView.contentOffset = CGPointMake(0.0, yOffset); 116 | } 117 | } 118 | 119 | #pragma mark - View Layout 120 | - (void)layoutParallaxView 121 | { 122 | CGRect bounds = self.view.bounds; 123 | _parallaxScrollView.frame = CGRectMake(0.0, 0.0, bounds.size.width, bounds.size.height); 124 | 125 | CGFloat width = _parallaxScrollView.frame.size.width; 126 | CGFloat yOffset = floorf((_parallaxHeight - ImageHeight) / 2.0); 127 | CGFloat xOffset = 0.0; 128 | 129 | _parallaxView.frame = CGRectMake(xOffset, yOffset, width, ImageHeight); 130 | _parallaxScrollView.contentSize = CGSizeMake(width, self.view.bounds.size.height); 131 | _parallaxScrollView.contentOffset = CGPointZero; 132 | } 133 | 134 | - (void)layoutContent 135 | { 136 | _contentScrollView.frame = self.view.bounds; 137 | 138 | CGFloat yOffset = _parallaxHeight; 139 | CGFloat xOffset = 0.0; 140 | 141 | CGSize contentSize = _contentView.frame.size; 142 | contentSize.height += yOffset; 143 | 144 | _contentView.frame = (CGRect){.origin = CGPointMake(xOffset, yOffset), .size = _contentView.frame.size}; 145 | _contentScrollView.contentSize = contentSize; 146 | } 147 | 148 | #pragma mark - View lifecycle 149 | 150 | - (void)viewWillAppear:(BOOL)animated 151 | { 152 | [super viewWillAppear:animated]; 153 | 154 | [self layoutParallaxView]; 155 | [self layoutContent]; 156 | 157 | [self updateOffsets]; 158 | } 159 | 160 | #pragma mark - UIScrollView Delegate 161 | // We want to allow external delegates without breaking functionality 162 | // This could be done better with a bit of runtime hacking, requires more research 163 | - (void)scrollViewDidScroll:(UIScrollView *)scrollView 164 | { 165 | if (scrollView == _contentScrollView) 166 | { 167 | [self updateOffsets]; 168 | 169 | if ([_contentDelegate respondsToSelector:@selector(scrollViewDidScroll:)]) 170 | { 171 | [_contentDelegate scrollViewDidScroll:scrollView]; 172 | } 173 | } 174 | } 175 | 176 | - (void)scrollViewDidZoom:(UIScrollView *)scrollView 177 | { 178 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewDidZoom:)]) 179 | { 180 | [_contentDelegate scrollViewDidZoom:scrollView]; 181 | } 182 | } 183 | 184 | - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView 185 | { 186 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewWillBeginDragging:)]) 187 | { 188 | [_contentDelegate scrollViewWillBeginDragging:scrollView]; 189 | } 190 | } 191 | 192 | - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset 193 | { 194 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)]) 195 | { 196 | [_contentDelegate scrollViewWillEndDragging:scrollView withVelocity:velocity targetContentOffset:targetContentOffset]; 197 | } 198 | } 199 | 200 | - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate 201 | { 202 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewDidEndDragging:willDecelerate:)]) 203 | { 204 | [_contentDelegate scrollViewDidEndDragging:scrollView willDecelerate:decelerate]; 205 | } 206 | } 207 | 208 | - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView 209 | { 210 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewWillBeginDecelerating:)]) 211 | { 212 | [_contentDelegate scrollViewWillBeginDecelerating:scrollView]; 213 | } 214 | } 215 | 216 | - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView 217 | { 218 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) 219 | { 220 | [_contentDelegate scrollViewDidEndDecelerating:scrollView]; 221 | } 222 | } 223 | 224 | - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView 225 | { 226 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewDidEndScrollingAnimation:)]) 227 | { 228 | [_contentDelegate scrollViewDidEndScrollingAnimation:scrollView]; 229 | } 230 | } 231 | 232 | - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 233 | { 234 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(viewForZoomingInScrollView:)]) 235 | { 236 | return [_contentDelegate viewForZoomingInScrollView:scrollView]; 237 | } 238 | return nil; 239 | } 240 | 241 | - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view 242 | { 243 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewWillBeginZooming:withView:)]) 244 | { 245 | [_contentDelegate scrollViewWillBeginZooming:scrollView withView:view]; 246 | } 247 | } 248 | 249 | - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale 250 | { 251 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewDidEndZooming:withView:atScale:)]) 252 | { 253 | [_contentDelegate scrollViewDidEndZooming:scrollView withView:view atScale:scale]; 254 | } 255 | } 256 | 257 | - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView 258 | { 259 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewShouldScrollToTop:)]) 260 | { 261 | return [_contentDelegate scrollViewShouldScrollToTop:scrollView]; 262 | } 263 | return NO; 264 | } 265 | 266 | - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView 267 | { 268 | if (scrollView == _contentScrollView && [_contentDelegate respondsToSelector:@selector(scrollViewDidScrollToTop:)]) 269 | { 270 | [_contentDelegate scrollViewDidScrollToTop:scrollView]; 271 | } 272 | } 273 | @end 274 | -------------------------------------------------------------------------------- /PXParallaxViewController/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /PXParallaxViewController/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PXParallaxViewController 4 | // 5 | // Created by Paddy O'Brien on 2012-08-14. 6 | // Copyright (c) 2012 500px. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "PXAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([PXAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PXParallaxViewController 2 | ======================== 3 | 4 | This parallax view controller is based on the excellent [RBParallaxTableViewController][1] 5 | but designed to allow any view to be the child views, not just a tableview. 6 | the content scrollview use delegate methods to update the offsets but will forward 7 | delegate methods is you set its delegate, currently this done a bit clumsily, I may revise 8 | this later using a bit of runtime manipulation. 9 | 10 | TODO: 11 | ----- 12 | - There are some constants borrowed from RBParallaxTableViewController that might better 13 | be computed properties for this kind of implementation. 14 | 15 | [1]: https://github.com/Rheeseyb/RBParallaxTableViewController -------------------------------------------------------------------------------- /shovel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tapi/PXParallaxViewController/63a26e64dc220ad6026b16ebc683288eb5521a93/shovel.png -------------------------------------------------------------------------------- /shovel@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tapi/PXParallaxViewController/63a26e64dc220ad6026b16ebc683288eb5521a93/shovel@2x.png -------------------------------------------------------------------------------- /testContentView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1296 5 | 12A269 6 | 2549 7 | 1187 8 | 624.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 1498 12 | 13 | 14 | IBProxyObject 15 | IBUILabel 16 | IBUIView 17 | 18 | 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | PluginDependencyRecalculationVersion 23 | 24 | 25 | 26 | 27 | IBFilesOwner 28 | IBCocoaTouchFramework 29 | 30 | 31 | IBFirstResponder 32 | IBCocoaTouchFramework 33 | 34 | 35 | 36 | 292 37 | 38 | 39 | 40 | 292 41 | {{20, 44}, {280, 372}} 42 | 43 | 44 | _NS:9 45 | NO 46 | YES 47 | 7 48 | NO 49 | IBCocoaTouchFramework 50 | 51 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 52 | 53 | 54 | 1 55 | MCAwIDAAA 56 | 57 | 58 | 0 59 | 10 60 | 0 61 | 62 | 1 63 | 17 64 | 65 | 66 | Helvetica 67 | 17 68 | 16 69 | 70 | 71 | 72 | {320, 460} 73 | 74 | 75 | 76 | 77 | 3 78 | MQA 79 | 80 | 2 81 | 82 | 83 | IBCocoaTouchFramework 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 0 92 | 93 | 94 | 95 | 96 | 97 | 1 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -1 106 | 107 | 108 | File's Owner 109 | 110 | 111 | -2 112 | 113 | 114 | 115 | 116 | 4 117 | 118 | 119 | 120 | 121 | 122 | 123 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 124 | UIResponder 125 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 126 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 127 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 128 | 129 | 130 | 131 | 132 | 133 | 4 134 | 135 | 136 | 0 137 | IBCocoaTouchFramework 138 | 139 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 140 | 141 | 142 | YES 143 | 3 144 | 1498 145 | 146 | 147 | --------------------------------------------------------------------------------