├── .gitignore ├── ParallaxCells.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── krishan.xcuserdatad │ └── xcschemes │ ├── ParallaxCells.xcscheme │ └── xcschememanagement.plist ├── ParallaxCells ├── AppDelegate.swift ├── CellModel.swift ├── ImageCell.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-40@2x.png │ │ ├── Icon-40@3x.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-Small@2x.png │ │ └── Icon-Small@3x.png │ ├── image0.imageset │ │ ├── Contents.json │ │ └── i1 01.02.17.jpg │ ├── image1.imageset │ │ ├── Contents.json │ │ └── i2 01.02.17.jpg │ ├── image2.imageset │ │ ├── Contents.json │ │ └── i3.jpg │ ├── image3.imageset │ │ ├── Contents.json │ │ └── i4.jpg │ └── image4.imageset │ │ ├── Contents.json │ │ └── i5.jpg ├── Info.plist ├── LaunchScreen.xib ├── Main.storyboard └── ViewController.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | -------------------------------------------------------------------------------- /ParallaxCells.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 328623921B8816FD00346850 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3286238B1B8816FD00346850 /* Images.xcassets */; }; 11 | 328623931B8816FD00346850 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3286238C1B8816FD00346850 /* LaunchScreen.xib */; }; 12 | 328623941B8816FD00346850 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3286238D1B8816FD00346850 /* Main.storyboard */; }; 13 | 328623951B8816FD00346850 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3286238E1B8816FD00346850 /* AppDelegate.swift */; }; 14 | 328623961B8816FD00346850 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3286238F1B8816FD00346850 /* ViewController.swift */; }; 15 | 328623971B8816FD00346850 /* ImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 328623901B8816FD00346850 /* ImageCell.swift */; }; 16 | 328623981B8816FD00346850 /* CellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 328623911B8816FD00346850 /* CellModel.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 328623661B8816C000346850 /* ParallaxCells.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ParallaxCells.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 3286236A1B8816C000346850 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 22 | 3286238B1B8816FD00346850 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 23 | 3286238C1B8816FD00346850 /* LaunchScreen.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LaunchScreen.xib; sourceTree = ""; }; 24 | 3286238D1B8816FD00346850 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 25 | 3286238E1B8816FD00346850 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 26 | 3286238F1B8816FD00346850 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 27 | 328623901B8816FD00346850 /* ImageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCell.swift; sourceTree = ""; }; 28 | 328623911B8816FD00346850 /* CellModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CellModel.swift; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 328623631B8816C000346850 /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 3286235D1B8816C000346850 = { 43 | isa = PBXGroup; 44 | children = ( 45 | 328623681B8816C000346850 /* ParallaxCells */, 46 | 328623671B8816C000346850 /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 328623671B8816C000346850 /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 328623661B8816C000346850 /* ParallaxCells.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 328623681B8816C000346850 /* ParallaxCells */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 328623691B8816C000346850 /* Supporting Files */, 62 | 3286238B1B8816FD00346850 /* Images.xcassets */, 63 | 3286238C1B8816FD00346850 /* LaunchScreen.xib */, 64 | 3286238D1B8816FD00346850 /* Main.storyboard */, 65 | 3286238E1B8816FD00346850 /* AppDelegate.swift */, 66 | 3286238F1B8816FD00346850 /* ViewController.swift */, 67 | 328623901B8816FD00346850 /* ImageCell.swift */, 68 | 328623911B8816FD00346850 /* CellModel.swift */, 69 | ); 70 | path = ParallaxCells; 71 | sourceTree = ""; 72 | }; 73 | 328623691B8816C000346850 /* Supporting Files */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 3286236A1B8816C000346850 /* Info.plist */, 77 | ); 78 | name = "Supporting Files"; 79 | sourceTree = ""; 80 | }; 81 | /* End PBXGroup section */ 82 | 83 | /* Begin PBXNativeTarget section */ 84 | 328623651B8816C000346850 /* ParallaxCells */ = { 85 | isa = PBXNativeTarget; 86 | buildConfigurationList = 328623851B8816C000346850 /* Build configuration list for PBXNativeTarget "ParallaxCells" */; 87 | buildPhases = ( 88 | 328623621B8816C000346850 /* Sources */, 89 | 328623631B8816C000346850 /* Frameworks */, 90 | 328623641B8816C000346850 /* Resources */, 91 | ); 92 | buildRules = ( 93 | ); 94 | dependencies = ( 95 | ); 96 | name = ParallaxCells; 97 | productName = ParallaxCells; 98 | productReference = 328623661B8816C000346850 /* ParallaxCells.app */; 99 | productType = "com.apple.product-type.application"; 100 | }; 101 | /* End PBXNativeTarget section */ 102 | 103 | /* Begin PBXProject section */ 104 | 3286235E1B8816C000346850 /* Project object */ = { 105 | isa = PBXProject; 106 | attributes = { 107 | LastUpgradeCheck = 0640; 108 | ORGANIZATIONNAME = "Rocko Labs"; 109 | TargetAttributes = { 110 | 328623651B8816C000346850 = { 111 | CreatedOnToolsVersion = 6.4; 112 | LastSwiftMigration = 0800; 113 | }; 114 | }; 115 | }; 116 | buildConfigurationList = 328623611B8816C000346850 /* Build configuration list for PBXProject "ParallaxCells" */; 117 | compatibilityVersion = "Xcode 3.2"; 118 | developmentRegion = English; 119 | hasScannedForEncodings = 0; 120 | knownRegions = ( 121 | en, 122 | Base, 123 | ); 124 | mainGroup = 3286235D1B8816C000346850; 125 | productRefGroup = 328623671B8816C000346850 /* Products */; 126 | projectDirPath = ""; 127 | projectRoot = ""; 128 | targets = ( 129 | 328623651B8816C000346850 /* ParallaxCells */, 130 | ); 131 | }; 132 | /* End PBXProject section */ 133 | 134 | /* Begin PBXResourcesBuildPhase section */ 135 | 328623641B8816C000346850 /* Resources */ = { 136 | isa = PBXResourcesBuildPhase; 137 | buildActionMask = 2147483647; 138 | files = ( 139 | 328623941B8816FD00346850 /* Main.storyboard in Resources */, 140 | 328623931B8816FD00346850 /* LaunchScreen.xib in Resources */, 141 | 328623921B8816FD00346850 /* Images.xcassets in Resources */, 142 | ); 143 | runOnlyForDeploymentPostprocessing = 0; 144 | }; 145 | /* End PBXResourcesBuildPhase section */ 146 | 147 | /* Begin PBXSourcesBuildPhase section */ 148 | 328623621B8816C000346850 /* Sources */ = { 149 | isa = PBXSourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 328623961B8816FD00346850 /* ViewController.swift in Sources */, 153 | 328623951B8816FD00346850 /* AppDelegate.swift in Sources */, 154 | 328623971B8816FD00346850 /* ImageCell.swift in Sources */, 155 | 328623981B8816FD00346850 /* CellModel.swift in Sources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXSourcesBuildPhase section */ 160 | 161 | /* Begin XCBuildConfiguration section */ 162 | 328623831B8816C000346850 /* Debug */ = { 163 | isa = XCBuildConfiguration; 164 | buildSettings = { 165 | ALWAYS_SEARCH_USER_PATHS = NO; 166 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 167 | CLANG_CXX_LIBRARY = "libc++"; 168 | CLANG_ENABLE_MODULES = YES; 169 | CLANG_ENABLE_OBJC_ARC = YES; 170 | CLANG_WARN_BOOL_CONVERSION = YES; 171 | CLANG_WARN_CONSTANT_CONVERSION = YES; 172 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 173 | CLANG_WARN_EMPTY_BODY = YES; 174 | CLANG_WARN_ENUM_CONVERSION = YES; 175 | CLANG_WARN_INT_CONVERSION = YES; 176 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 177 | CLANG_WARN_UNREACHABLE_CODE = YES; 178 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 179 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 180 | COPY_PHASE_STRIP = NO; 181 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 182 | ENABLE_STRICT_OBJC_MSGSEND = YES; 183 | GCC_C_LANGUAGE_STANDARD = gnu99; 184 | GCC_DYNAMIC_NO_PIC = NO; 185 | GCC_NO_COMMON_BLOCKS = YES; 186 | GCC_OPTIMIZATION_LEVEL = 0; 187 | GCC_PREPROCESSOR_DEFINITIONS = ( 188 | "DEBUG=1", 189 | "$(inherited)", 190 | ); 191 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 192 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 193 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 194 | GCC_WARN_UNDECLARED_SELECTOR = YES; 195 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 196 | GCC_WARN_UNUSED_FUNCTION = YES; 197 | GCC_WARN_UNUSED_VARIABLE = YES; 198 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 199 | MTL_ENABLE_DEBUG_INFO = YES; 200 | ONLY_ACTIVE_ARCH = YES; 201 | SDKROOT = iphoneos; 202 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 203 | }; 204 | name = Debug; 205 | }; 206 | 328623841B8816C000346850 /* Release */ = { 207 | isa = XCBuildConfiguration; 208 | buildSettings = { 209 | ALWAYS_SEARCH_USER_PATHS = NO; 210 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 211 | CLANG_CXX_LIBRARY = "libc++"; 212 | CLANG_ENABLE_MODULES = YES; 213 | CLANG_ENABLE_OBJC_ARC = YES; 214 | CLANG_WARN_BOOL_CONVERSION = YES; 215 | CLANG_WARN_CONSTANT_CONVERSION = YES; 216 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 217 | CLANG_WARN_EMPTY_BODY = YES; 218 | CLANG_WARN_ENUM_CONVERSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 221 | CLANG_WARN_UNREACHABLE_CODE = YES; 222 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 223 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 224 | COPY_PHASE_STRIP = NO; 225 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 226 | ENABLE_NS_ASSERTIONS = NO; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | GCC_C_LANGUAGE_STANDARD = gnu99; 229 | GCC_NO_COMMON_BLOCKS = YES; 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 = 8.0; 237 | MTL_ENABLE_DEBUG_INFO = NO; 238 | SDKROOT = iphoneos; 239 | VALIDATE_PRODUCT = YES; 240 | }; 241 | name = Release; 242 | }; 243 | 328623861B8816C000346850 /* Debug */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 247 | CLANG_ENABLE_MODULES = YES; 248 | INFOPLIST_FILE = ParallaxCells/Info.plist; 249 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 250 | PRODUCT_NAME = "$(TARGET_NAME)"; 251 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 252 | SWIFT_VERSION = 3.0; 253 | }; 254 | name = Debug; 255 | }; 256 | 328623871B8816C000346850 /* Release */ = { 257 | isa = XCBuildConfiguration; 258 | buildSettings = { 259 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 260 | CLANG_ENABLE_MODULES = YES; 261 | INFOPLIST_FILE = ParallaxCells/Info.plist; 262 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 263 | PRODUCT_NAME = "$(TARGET_NAME)"; 264 | SWIFT_VERSION = 3.0; 265 | }; 266 | name = Release; 267 | }; 268 | /* End XCBuildConfiguration section */ 269 | 270 | /* Begin XCConfigurationList section */ 271 | 328623611B8816C000346850 /* Build configuration list for PBXProject "ParallaxCells" */ = { 272 | isa = XCConfigurationList; 273 | buildConfigurations = ( 274 | 328623831B8816C000346850 /* Debug */, 275 | 328623841B8816C000346850 /* Release */, 276 | ); 277 | defaultConfigurationIsVisible = 0; 278 | defaultConfigurationName = Release; 279 | }; 280 | 328623851B8816C000346850 /* Build configuration list for PBXNativeTarget "ParallaxCells" */ = { 281 | isa = XCConfigurationList; 282 | buildConfigurations = ( 283 | 328623861B8816C000346850 /* Debug */, 284 | 328623871B8816C000346850 /* Release */, 285 | ); 286 | defaultConfigurationIsVisible = 0; 287 | defaultConfigurationName = Release; 288 | }; 289 | /* End XCConfigurationList section */ 290 | }; 291 | rootObject = 3286235E1B8816C000346850 /* Project object */; 292 | } 293 | -------------------------------------------------------------------------------- /ParallaxCells.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ParallaxCells.xcodeproj/xcuserdata/krishan.xcuserdatad/xcschemes/ParallaxCells.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /ParallaxCells.xcodeproj/xcuserdata/krishan.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ParallaxCells.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 328623651B8816C000346850 16 | 17 | primary 18 | 19 | 20 | 3286237A1B8816C000346850 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ParallaxCells/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ParallaxCells 4 | // 5 | // Created by Krishan Patel on 22/08/2015. 6 | // Copyright (c) 2015 Rocko Labs. 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 throttle down OpenGL ES frame rates. 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 inactive 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 | -------------------------------------------------------------------------------- /ParallaxCells/CellModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Model.swift 3 | // ParallaxCells 4 | // 5 | // Created by Krishan Patel on 22/08/2015. 6 | // Copyright (c) 2015 Rocko Labs. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class CellModel { 12 | 13 | var title: String 14 | var imageName: String 15 | 16 | init(title:String, imageName:String) { 17 | self.title = title 18 | self.imageName = imageName 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /ParallaxCells/ImageCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageCell.swift 3 | // ParallaxCells 4 | // 5 | // Created by Krishan Patel on 22/08/2015. 6 | // Copyright (c) 2015 Rocko Labs. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ImageCell: UITableViewCell { 12 | 13 | @IBOutlet weak var lblTitle: UILabel! 14 | @IBOutlet weak var imgBack: UIImageView! 15 | @IBOutlet weak var imgBackTopConstraint: NSLayoutConstraint! 16 | @IBOutlet weak var imgBackBottomConstraint: NSLayoutConstraint! 17 | 18 | let imageParallaxFactor: CGFloat = 70 19 | 20 | var imgBackTopInitial: CGFloat! 21 | var imgBackBottomInitial: CGFloat! 22 | 23 | var model: CellModel! { 24 | didSet { 25 | self.updateView() 26 | } 27 | } 28 | 29 | override func awakeFromNib() { 30 | self.clipsToBounds = true 31 | self.imgBackBottomConstraint.constant -= 2 * imageParallaxFactor 32 | self.imgBackTopInitial = self.imgBackTopConstraint.constant 33 | self.imgBackBottomInitial = self.imgBackBottomConstraint.constant 34 | } 35 | 36 | func updateView() { 37 | self.imgBack.image = UIImage(named:self.model.imageName) 38 | self.lblTitle.text = self.model.title 39 | } 40 | 41 | func setBackgroundOffset(_ offset:CGFloat) { 42 | let boundOffset = max(0, min(1, offset)) 43 | let pixelOffset = (1-boundOffset)*2*imageParallaxFactor 44 | self.imgBackTopConstraint.constant = self.imgBackTopInitial - pixelOffset 45 | self.imgBackBottomConstraint.constant = self.imgBackBottomInitial + pixelOffset 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-Small@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-Small@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-40@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-40@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-60@3x.png", 37 | "scale" : "3x" 38 | } 39 | ], 40 | "info" : { 41 | "version" : 1, 42 | "author" : "xcode" 43 | } 44 | } -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-Small@2x.png -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image0.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "i1 01.02.17.jpg" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image0.imageset/i1 01.02.17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/image0.imageset/i1 01.02.17.jpg -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image1.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "i2 01.02.17.jpg" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image1.imageset/i2 01.02.17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/image1.imageset/i2 01.02.17.jpg -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "i3.jpg" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image2.imageset/i3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/image2.imageset/i3.jpg -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image3.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "i4.jpg" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image3.imageset/i4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/image3.imageset/i4.jpg -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image4.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "i5.jpg" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /ParallaxCells/Images.xcassets/image4.imageset/i5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/krishan711/ParallaxCells-iOS/032b2f15a0c04a76ea17ada543d5dad0a81df2ec/ParallaxCells/Images.xcassets/image4.imageset/i5.jpg -------------------------------------------------------------------------------- /ParallaxCells/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.rockolabs.blog.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /ParallaxCells/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /ParallaxCells/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /ParallaxCells/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ParallaxCells 4 | // 5 | // Created by Krishan Patel on 22/08/2015. 6 | // Copyright (c) 2015 Rocko Labs. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 12 | 13 | @IBOutlet weak var tblMain: UITableView! 14 | 15 | var models: [CellModel] = [] 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | self.tblMain.delegate = self 20 | self.tblMain.dataSource = self 21 | self.tblMain.rowHeight = 250 22 | 23 | self.models.append(CellModel(title: "Title 0", imageName: "image0")) 24 | self.models.append(CellModel(title: "Title 1", imageName: "image1")) 25 | self.models.append(CellModel(title: "Title 2", imageName: "image2")) 26 | self.models.append(CellModel(title: "Title 3", imageName: "image3")) 27 | self.models.append(CellModel(title: "Title 4", imageName: "image4")) 28 | } 29 | 30 | func numberOfSections(in tableView: UITableView) -> Int { 31 | return 1 32 | } 33 | 34 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 35 | if (section == 0) { 36 | return self.models.count * 100 37 | } 38 | return 0 39 | } 40 | func modelAtIndexPath(_ indexPath: IndexPath) -> CellModel { 41 | return self.models[(indexPath as NSIndexPath).row % self.models.count] 42 | } 43 | 44 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 45 | let cell = tableView.dequeueReusableCell(withIdentifier: "ImageCell") as! ImageCell 46 | cell.model = self.modelAtIndexPath(indexPath) 47 | return cell 48 | } 49 | 50 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 51 | tableView.deselectRow(at: indexPath, animated:true) 52 | } 53 | 54 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 55 | if (scrollView == self.tblMain) { 56 | for indexPath in self.tblMain.indexPathsForVisibleRows! { 57 | self.setCellImageOffset(self.tblMain.cellForRow(at: indexPath) as! ImageCell, indexPath: indexPath) 58 | } 59 | } 60 | } 61 | 62 | func setCellImageOffset(_ cell: ImageCell, indexPath: IndexPath) { 63 | let cellFrame = self.tblMain.rectForRow(at: indexPath) 64 | let cellFrameInTable = self.tblMain.convert(cellFrame, to:self.tblMain.superview) 65 | let cellOffset = cellFrameInTable.origin.y + cellFrameInTable.size.height 66 | let tableHeight = self.tblMain.bounds.size.height + cellFrameInTable.size.height 67 | let cellOffsetFactor = cellOffset / tableHeight 68 | cell.setBackgroundOffset(cellOffsetFactor) 69 | } 70 | 71 | func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 72 | let imageCell = cell as! ImageCell 73 | self.setCellImageOffset(imageCell, indexPath: indexPath) 74 | } 75 | 76 | } 77 | 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ParallaxCells-iOS 2 | 3 | A Quick project showing a super-slick way of implementing parallax scrolling on uitableview cells with Auto Layout. 4 | 5 | You can read the blog post here: http://blog.krishan711.com/gorgeous-parallax-scrolling-with-uitableviewcells 6 | 7 | ## This is a Swift 3 migration 8 | --------------------------------------------------------------------------------