├── ParallaxBackgroundSwift.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── jhall.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── ParallaxBackgroundSwift.xcscheme │ └── xcschememanagement.plist ├── ParallaxBackgroundSwift ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── ChooseOrientationViewController.swift ├── Info.plist ├── ParallaxBackgroundDirection.swift ├── ParallaxScene.swift ├── ParallaxScrolling.swift ├── ViewController.swift ├── pBackgroundHorizontal.png ├── pBackgroundHorizontal@2x.png ├── pBackgroundVertical.png ├── pBackgroundVertical@2x.png ├── pForegroundHorizontal.png ├── pForegroundHorizontal@2x.png ├── pForegroundVertical.png ├── pForegroundVertical@2x.png ├── pGraph@2x.png ├── pGraph@3x.png ├── pMiddleHorizontal.png ├── pMiddleHorizontal@2x.png ├── pMiddleVertical.png └── pMiddleVertical@2x.png ├── README.md └── parralax.gif /ParallaxBackgroundSwift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DC30CF4C1F3A265400C3D773 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC30CF4B1F3A265400C3D773 /* AppDelegate.swift */; }; 11 | DC30CF4E1F3A265400C3D773 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC30CF4D1F3A265400C3D773 /* ViewController.swift */; }; 12 | DC30CF511F3A265400C3D773 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF4F1F3A265400C3D773 /* Main.storyboard */; }; 13 | DC30CF531F3A265400C3D773 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF521F3A265400C3D773 /* Assets.xcassets */; }; 14 | DC30CF561F3A265400C3D773 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF541F3A265400C3D773 /* LaunchScreen.storyboard */; }; 15 | DC30CF5E1F3A2BB100C3D773 /* ParallaxBackgroundDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC30CF5D1F3A2BB100C3D773 /* ParallaxBackgroundDirection.swift */; }; 16 | DC30CF601F3A2E6700C3D773 /* ChooseOrientationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC30CF5F1F3A2E6700C3D773 /* ChooseOrientationViewController.swift */; }; 17 | DC30CF621F3A35FF00C3D773 /* ParallaxScrolling.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC30CF611F3A35FF00C3D773 /* ParallaxScrolling.swift */; }; 18 | DC30CF641F3A382900C3D773 /* ParallaxScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC30CF631F3A382900C3D773 /* ParallaxScene.swift */; }; 19 | DC30CF721F3A3A2200C3D773 /* pBackgroundHorizontal.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF661F3A3A2200C3D773 /* pBackgroundHorizontal.png */; }; 20 | DC30CF731F3A3A2200C3D773 /* pBackgroundHorizontal@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF671F3A3A2200C3D773 /* pBackgroundHorizontal@2x.png */; }; 21 | DC30CF741F3A3A2200C3D773 /* pBackgroundVertical.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF681F3A3A2200C3D773 /* pBackgroundVertical.png */; }; 22 | DC30CF751F3A3A2200C3D773 /* pBackgroundVertical@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF691F3A3A2200C3D773 /* pBackgroundVertical@2x.png */; }; 23 | DC30CF761F3A3A2200C3D773 /* pForegroundHorizontal.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF6A1F3A3A2200C3D773 /* pForegroundHorizontal.png */; }; 24 | DC30CF771F3A3A2200C3D773 /* pForegroundHorizontal@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF6B1F3A3A2200C3D773 /* pForegroundHorizontal@2x.png */; }; 25 | DC30CF781F3A3A2200C3D773 /* pForegroundVertical.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF6C1F3A3A2200C3D773 /* pForegroundVertical.png */; }; 26 | DC30CF791F3A3A2200C3D773 /* pForegroundVertical@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF6D1F3A3A2200C3D773 /* pForegroundVertical@2x.png */; }; 27 | DC30CF7A1F3A3A2200C3D773 /* pMiddleHorizontal.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF6E1F3A3A2200C3D773 /* pMiddleHorizontal.png */; }; 28 | DC30CF7B1F3A3A2200C3D773 /* pMiddleHorizontal@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF6F1F3A3A2200C3D773 /* pMiddleHorizontal@2x.png */; }; 29 | DC30CF7C1F3A3A2200C3D773 /* pMiddleVertical.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF701F3A3A2200C3D773 /* pMiddleVertical.png */; }; 30 | DC30CF7D1F3A3A2200C3D773 /* pMiddleVertical@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC30CF711F3A3A2200C3D773 /* pMiddleVertical@2x.png */; }; 31 | DC8AF9EE1F3BBC1C00EB198D /* pGraph@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC8AF9EC1F3BBC1C00EB198D /* pGraph@3x.png */; }; 32 | DC8AF9EF1F3BBC1C00EB198D /* pGraph@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = DC8AF9ED1F3BBC1C00EB198D /* pGraph@2x.png */; }; 33 | /* End PBXBuildFile section */ 34 | 35 | /* Begin PBXFileReference section */ 36 | DC30CF481F3A265400C3D773 /* ParallaxBackgroundSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ParallaxBackgroundSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 37 | DC30CF4B1F3A265400C3D773 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 38 | DC30CF4D1F3A265400C3D773 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 39 | DC30CF501F3A265400C3D773 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 40 | DC30CF521F3A265400C3D773 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 41 | DC30CF551F3A265400C3D773 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 42 | DC30CF571F3A265400C3D773 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | DC30CF5D1F3A2BB100C3D773 /* ParallaxBackgroundDirection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParallaxBackgroundDirection.swift; sourceTree = ""; }; 44 | DC30CF5F1F3A2E6700C3D773 /* ChooseOrientationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseOrientationViewController.swift; sourceTree = ""; }; 45 | DC30CF611F3A35FF00C3D773 /* ParallaxScrolling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParallaxScrolling.swift; sourceTree = ""; }; 46 | DC30CF631F3A382900C3D773 /* ParallaxScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParallaxScene.swift; sourceTree = ""; }; 47 | DC30CF661F3A3A2200C3D773 /* pBackgroundHorizontal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pBackgroundHorizontal.png; sourceTree = ""; }; 48 | DC30CF671F3A3A2200C3D773 /* pBackgroundHorizontal@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pBackgroundHorizontal@2x.png"; sourceTree = ""; }; 49 | DC30CF681F3A3A2200C3D773 /* pBackgroundVertical.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pBackgroundVertical.png; sourceTree = ""; }; 50 | DC30CF691F3A3A2200C3D773 /* pBackgroundVertical@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pBackgroundVertical@2x.png"; sourceTree = ""; }; 51 | DC30CF6A1F3A3A2200C3D773 /* pForegroundHorizontal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pForegroundHorizontal.png; sourceTree = ""; }; 52 | DC30CF6B1F3A3A2200C3D773 /* pForegroundHorizontal@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pForegroundHorizontal@2x.png"; sourceTree = ""; }; 53 | DC30CF6C1F3A3A2200C3D773 /* pForegroundVertical.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pForegroundVertical.png; sourceTree = ""; }; 54 | DC30CF6D1F3A3A2200C3D773 /* pForegroundVertical@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pForegroundVertical@2x.png"; sourceTree = ""; }; 55 | DC30CF6E1F3A3A2200C3D773 /* pMiddleHorizontal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pMiddleHorizontal.png; sourceTree = ""; }; 56 | DC30CF6F1F3A3A2200C3D773 /* pMiddleHorizontal@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pMiddleHorizontal@2x.png"; sourceTree = ""; }; 57 | DC30CF701F3A3A2200C3D773 /* pMiddleVertical.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pMiddleVertical.png; sourceTree = ""; }; 58 | DC30CF711F3A3A2200C3D773 /* pMiddleVertical@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pMiddleVertical@2x.png"; sourceTree = ""; }; 59 | DC8AF9EC1F3BBC1C00EB198D /* pGraph@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pGraph@3x.png"; sourceTree = ""; }; 60 | DC8AF9ED1F3BBC1C00EB198D /* pGraph@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pGraph@2x.png"; sourceTree = ""; }; 61 | /* End PBXFileReference section */ 62 | 63 | /* Begin PBXFrameworksBuildPhase section */ 64 | DC30CF451F3A265400C3D773 /* Frameworks */ = { 65 | isa = PBXFrameworksBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | ); 69 | runOnlyForDeploymentPostprocessing = 0; 70 | }; 71 | /* End PBXFrameworksBuildPhase section */ 72 | 73 | /* Begin PBXGroup section */ 74 | DC30CF3F1F3A265400C3D773 = { 75 | isa = PBXGroup; 76 | children = ( 77 | DC30CF4A1F3A265400C3D773 /* ParallaxBackgroundSwift */, 78 | DC30CF491F3A265400C3D773 /* Products */, 79 | ); 80 | sourceTree = ""; 81 | }; 82 | DC30CF491F3A265400C3D773 /* Products */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | DC30CF481F3A265400C3D773 /* ParallaxBackgroundSwift.app */, 86 | ); 87 | name = Products; 88 | sourceTree = ""; 89 | }; 90 | DC30CF4A1F3A265400C3D773 /* ParallaxBackgroundSwift */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | DC30CF651F3A3A1000C3D773 /* Images */, 94 | DC30CF4B1F3A265400C3D773 /* AppDelegate.swift */, 95 | DC30CF4D1F3A265400C3D773 /* ViewController.swift */, 96 | DC30CF4F1F3A265400C3D773 /* Main.storyboard */, 97 | DC30CF521F3A265400C3D773 /* Assets.xcassets */, 98 | DC30CF541F3A265400C3D773 /* LaunchScreen.storyboard */, 99 | DC30CF571F3A265400C3D773 /* Info.plist */, 100 | DC30CF5D1F3A2BB100C3D773 /* ParallaxBackgroundDirection.swift */, 101 | DC30CF5F1F3A2E6700C3D773 /* ChooseOrientationViewController.swift */, 102 | DC30CF611F3A35FF00C3D773 /* ParallaxScrolling.swift */, 103 | DC30CF631F3A382900C3D773 /* ParallaxScene.swift */, 104 | ); 105 | path = ParallaxBackgroundSwift; 106 | sourceTree = ""; 107 | }; 108 | DC30CF651F3A3A1000C3D773 /* Images */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | DC8AF9EC1F3BBC1C00EB198D /* pGraph@3x.png */, 112 | DC8AF9ED1F3BBC1C00EB198D /* pGraph@2x.png */, 113 | DC30CF661F3A3A2200C3D773 /* pBackgroundHorizontal.png */, 114 | DC30CF671F3A3A2200C3D773 /* pBackgroundHorizontal@2x.png */, 115 | DC30CF681F3A3A2200C3D773 /* pBackgroundVertical.png */, 116 | DC30CF691F3A3A2200C3D773 /* pBackgroundVertical@2x.png */, 117 | DC30CF6A1F3A3A2200C3D773 /* pForegroundHorizontal.png */, 118 | DC30CF6B1F3A3A2200C3D773 /* pForegroundHorizontal@2x.png */, 119 | DC30CF6C1F3A3A2200C3D773 /* pForegroundVertical.png */, 120 | DC30CF6D1F3A3A2200C3D773 /* pForegroundVertical@2x.png */, 121 | DC30CF6E1F3A3A2200C3D773 /* pMiddleHorizontal.png */, 122 | DC30CF6F1F3A3A2200C3D773 /* pMiddleHorizontal@2x.png */, 123 | DC30CF701F3A3A2200C3D773 /* pMiddleVertical.png */, 124 | DC30CF711F3A3A2200C3D773 /* pMiddleVertical@2x.png */, 125 | ); 126 | name = Images; 127 | sourceTree = ""; 128 | }; 129 | /* End PBXGroup section */ 130 | 131 | /* Begin PBXNativeTarget section */ 132 | DC30CF471F3A265400C3D773 /* ParallaxBackgroundSwift */ = { 133 | isa = PBXNativeTarget; 134 | buildConfigurationList = DC30CF5A1F3A265400C3D773 /* Build configuration list for PBXNativeTarget "ParallaxBackgroundSwift" */; 135 | buildPhases = ( 136 | DC30CF441F3A265400C3D773 /* Sources */, 137 | DC30CF451F3A265400C3D773 /* Frameworks */, 138 | DC30CF461F3A265400C3D773 /* Resources */, 139 | ); 140 | buildRules = ( 141 | ); 142 | dependencies = ( 143 | ); 144 | name = ParallaxBackgroundSwift; 145 | productName = ParallaxBackgroundSwift; 146 | productReference = DC30CF481F3A265400C3D773 /* ParallaxBackgroundSwift.app */; 147 | productType = "com.apple.product-type.application"; 148 | }; 149 | /* End PBXNativeTarget section */ 150 | 151 | /* Begin PBXProject section */ 152 | DC30CF401F3A265400C3D773 /* Project object */ = { 153 | isa = PBXProject; 154 | attributes = { 155 | LastSwiftUpdateCheck = 0830; 156 | LastUpgradeCheck = 0830; 157 | ORGANIZATIONNAME = jhall; 158 | TargetAttributes = { 159 | DC30CF471F3A265400C3D773 = { 160 | CreatedOnToolsVersion = 8.3.3; 161 | DevelopmentTeam = PBVUXBPDEA; 162 | ProvisioningStyle = Automatic; 163 | }; 164 | }; 165 | }; 166 | buildConfigurationList = DC30CF431F3A265400C3D773 /* Build configuration list for PBXProject "ParallaxBackgroundSwift" */; 167 | compatibilityVersion = "Xcode 3.2"; 168 | developmentRegion = English; 169 | hasScannedForEncodings = 0; 170 | knownRegions = ( 171 | en, 172 | Base, 173 | ); 174 | mainGroup = DC30CF3F1F3A265400C3D773; 175 | productRefGroup = DC30CF491F3A265400C3D773 /* Products */; 176 | projectDirPath = ""; 177 | projectRoot = ""; 178 | targets = ( 179 | DC30CF471F3A265400C3D773 /* ParallaxBackgroundSwift */, 180 | ); 181 | }; 182 | /* End PBXProject section */ 183 | 184 | /* Begin PBXResourcesBuildPhase section */ 185 | DC30CF461F3A265400C3D773 /* Resources */ = { 186 | isa = PBXResourcesBuildPhase; 187 | buildActionMask = 2147483647; 188 | files = ( 189 | DC30CF561F3A265400C3D773 /* LaunchScreen.storyboard in Resources */, 190 | DC30CF7A1F3A3A2200C3D773 /* pMiddleHorizontal.png in Resources */, 191 | DC30CF761F3A3A2200C3D773 /* pForegroundHorizontal.png in Resources */, 192 | DC30CF731F3A3A2200C3D773 /* pBackgroundHorizontal@2x.png in Resources */, 193 | DC30CF741F3A3A2200C3D773 /* pBackgroundVertical.png in Resources */, 194 | DC30CF751F3A3A2200C3D773 /* pBackgroundVertical@2x.png in Resources */, 195 | DC30CF781F3A3A2200C3D773 /* pForegroundVertical.png in Resources */, 196 | DC30CF7C1F3A3A2200C3D773 /* pMiddleVertical.png in Resources */, 197 | DC8AF9EF1F3BBC1C00EB198D /* pGraph@2x.png in Resources */, 198 | DC30CF791F3A3A2200C3D773 /* pForegroundVertical@2x.png in Resources */, 199 | DC30CF531F3A265400C3D773 /* Assets.xcassets in Resources */, 200 | DC30CF721F3A3A2200C3D773 /* pBackgroundHorizontal.png in Resources */, 201 | DC30CF511F3A265400C3D773 /* Main.storyboard in Resources */, 202 | DC30CF7D1F3A3A2200C3D773 /* pMiddleVertical@2x.png in Resources */, 203 | DC8AF9EE1F3BBC1C00EB198D /* pGraph@3x.png in Resources */, 204 | DC30CF7B1F3A3A2200C3D773 /* pMiddleHorizontal@2x.png in Resources */, 205 | DC30CF771F3A3A2200C3D773 /* pForegroundHorizontal@2x.png in Resources */, 206 | ); 207 | runOnlyForDeploymentPostprocessing = 0; 208 | }; 209 | /* End PBXResourcesBuildPhase section */ 210 | 211 | /* Begin PBXSourcesBuildPhase section */ 212 | DC30CF441F3A265400C3D773 /* Sources */ = { 213 | isa = PBXSourcesBuildPhase; 214 | buildActionMask = 2147483647; 215 | files = ( 216 | DC30CF641F3A382900C3D773 /* ParallaxScene.swift in Sources */, 217 | DC30CF601F3A2E6700C3D773 /* ChooseOrientationViewController.swift in Sources */, 218 | DC30CF621F3A35FF00C3D773 /* ParallaxScrolling.swift in Sources */, 219 | DC30CF4E1F3A265400C3D773 /* ViewController.swift in Sources */, 220 | DC30CF4C1F3A265400C3D773 /* AppDelegate.swift in Sources */, 221 | DC30CF5E1F3A2BB100C3D773 /* ParallaxBackgroundDirection.swift in Sources */, 222 | ); 223 | runOnlyForDeploymentPostprocessing = 0; 224 | }; 225 | /* End PBXSourcesBuildPhase section */ 226 | 227 | /* Begin PBXVariantGroup section */ 228 | DC30CF4F1F3A265400C3D773 /* Main.storyboard */ = { 229 | isa = PBXVariantGroup; 230 | children = ( 231 | DC30CF501F3A265400C3D773 /* Base */, 232 | ); 233 | name = Main.storyboard; 234 | sourceTree = ""; 235 | }; 236 | DC30CF541F3A265400C3D773 /* LaunchScreen.storyboard */ = { 237 | isa = PBXVariantGroup; 238 | children = ( 239 | DC30CF551F3A265400C3D773 /* Base */, 240 | ); 241 | name = LaunchScreen.storyboard; 242 | sourceTree = ""; 243 | }; 244 | /* End PBXVariantGroup section */ 245 | 246 | /* Begin XCBuildConfiguration section */ 247 | DC30CF581F3A265400C3D773 /* Debug */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | ALWAYS_SEARCH_USER_PATHS = NO; 251 | CLANG_ANALYZER_NONNULL = YES; 252 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 253 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 254 | CLANG_CXX_LIBRARY = "libc++"; 255 | CLANG_ENABLE_MODULES = YES; 256 | CLANG_ENABLE_OBJC_ARC = YES; 257 | CLANG_WARN_BOOL_CONVERSION = YES; 258 | CLANG_WARN_CONSTANT_CONVERSION = YES; 259 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 260 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 261 | CLANG_WARN_EMPTY_BODY = YES; 262 | CLANG_WARN_ENUM_CONVERSION = YES; 263 | CLANG_WARN_INFINITE_RECURSION = YES; 264 | CLANG_WARN_INT_CONVERSION = YES; 265 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 266 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 267 | CLANG_WARN_UNREACHABLE_CODE = YES; 268 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 269 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 270 | COPY_PHASE_STRIP = NO; 271 | DEBUG_INFORMATION_FORMAT = dwarf; 272 | ENABLE_STRICT_OBJC_MSGSEND = YES; 273 | ENABLE_TESTABILITY = YES; 274 | GCC_C_LANGUAGE_STANDARD = gnu99; 275 | GCC_DYNAMIC_NO_PIC = NO; 276 | GCC_NO_COMMON_BLOCKS = YES; 277 | GCC_OPTIMIZATION_LEVEL = 0; 278 | GCC_PREPROCESSOR_DEFINITIONS = ( 279 | "DEBUG=1", 280 | "$(inherited)", 281 | ); 282 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 283 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 284 | GCC_WARN_UNDECLARED_SELECTOR = YES; 285 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 286 | GCC_WARN_UNUSED_FUNCTION = YES; 287 | GCC_WARN_UNUSED_VARIABLE = YES; 288 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 289 | MTL_ENABLE_DEBUG_INFO = YES; 290 | ONLY_ACTIVE_ARCH = YES; 291 | SDKROOT = iphoneos; 292 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 293 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 294 | }; 295 | name = Debug; 296 | }; 297 | DC30CF591F3A265400C3D773 /* Release */ = { 298 | isa = XCBuildConfiguration; 299 | buildSettings = { 300 | ALWAYS_SEARCH_USER_PATHS = NO; 301 | CLANG_ANALYZER_NONNULL = YES; 302 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 303 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 304 | CLANG_CXX_LIBRARY = "libc++"; 305 | CLANG_ENABLE_MODULES = YES; 306 | CLANG_ENABLE_OBJC_ARC = YES; 307 | CLANG_WARN_BOOL_CONVERSION = YES; 308 | CLANG_WARN_CONSTANT_CONVERSION = YES; 309 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 310 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 311 | CLANG_WARN_EMPTY_BODY = YES; 312 | CLANG_WARN_ENUM_CONVERSION = YES; 313 | CLANG_WARN_INFINITE_RECURSION = YES; 314 | CLANG_WARN_INT_CONVERSION = YES; 315 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 316 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 317 | CLANG_WARN_UNREACHABLE_CODE = YES; 318 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 319 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 320 | COPY_PHASE_STRIP = NO; 321 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 322 | ENABLE_NS_ASSERTIONS = NO; 323 | ENABLE_STRICT_OBJC_MSGSEND = YES; 324 | GCC_C_LANGUAGE_STANDARD = gnu99; 325 | GCC_NO_COMMON_BLOCKS = YES; 326 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 327 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 328 | GCC_WARN_UNDECLARED_SELECTOR = YES; 329 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 330 | GCC_WARN_UNUSED_FUNCTION = YES; 331 | GCC_WARN_UNUSED_VARIABLE = YES; 332 | IPHONEOS_DEPLOYMENT_TARGET = 10.3; 333 | MTL_ENABLE_DEBUG_INFO = NO; 334 | SDKROOT = iphoneos; 335 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 336 | VALIDATE_PRODUCT = YES; 337 | }; 338 | name = Release; 339 | }; 340 | DC30CF5B1F3A265400C3D773 /* Debug */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 344 | DEVELOPMENT_TEAM = PBVUXBPDEA; 345 | INFOPLIST_FILE = ParallaxBackgroundSwift/Info.plist; 346 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 347 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 348 | PRODUCT_BUNDLE_IDENTIFIER = com.jhall.ParallaxBackgroundSwift; 349 | PRODUCT_NAME = "$(TARGET_NAME)"; 350 | SWIFT_VERSION = 3.0; 351 | }; 352 | name = Debug; 353 | }; 354 | DC30CF5C1F3A265400C3D773 /* Release */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 358 | DEVELOPMENT_TEAM = PBVUXBPDEA; 359 | INFOPLIST_FILE = ParallaxBackgroundSwift/Info.plist; 360 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 361 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 362 | PRODUCT_BUNDLE_IDENTIFIER = com.jhall.ParallaxBackgroundSwift; 363 | PRODUCT_NAME = "$(TARGET_NAME)"; 364 | SWIFT_VERSION = 3.0; 365 | }; 366 | name = Release; 367 | }; 368 | /* End XCBuildConfiguration section */ 369 | 370 | /* Begin XCConfigurationList section */ 371 | DC30CF431F3A265400C3D773 /* Build configuration list for PBXProject "ParallaxBackgroundSwift" */ = { 372 | isa = XCConfigurationList; 373 | buildConfigurations = ( 374 | DC30CF581F3A265400C3D773 /* Debug */, 375 | DC30CF591F3A265400C3D773 /* Release */, 376 | ); 377 | defaultConfigurationIsVisible = 0; 378 | defaultConfigurationName = Release; 379 | }; 380 | DC30CF5A1F3A265400C3D773 /* Build configuration list for PBXNativeTarget "ParallaxBackgroundSwift" */ = { 381 | isa = XCConfigurationList; 382 | buildConfigurations = ( 383 | DC30CF5B1F3A265400C3D773 /* Debug */, 384 | DC30CF5C1F3A265400C3D773 /* Release */, 385 | ); 386 | defaultConfigurationIsVisible = 0; 387 | defaultConfigurationName = Release; 388 | }; 389 | /* End XCConfigurationList section */ 390 | }; 391 | rootObject = DC30CF401F3A265400C3D773 /* Project object */; 392 | } 393 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift.xcodeproj/xcuserdata/jhall.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift.xcodeproj/xcuserdata/jhall.xcuserdatad/xcschemes/ParallaxBackgroundSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift.xcodeproj/xcuserdata/jhall.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ParallaxBackgroundSwift.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DC30CF471F3A265400C3D773 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ParallaxBackgroundSwift 4 | // 5 | // Created by Justin Hall on 8/8/17. 6 | // Copyright © 2017 jhall. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/Assets.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" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 32 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 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 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/ChooseOrientationViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChooseOrientationViewController.swift 3 | // ParallaxBackgroundSwift 4 | // 5 | // Created by Justin Hall on 8/8/17. 6 | // Copyright © 2017 jhall. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ChooseOrientationViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | // Do any additional setup after loading the view. 17 | } 18 | 19 | // MARK: - Navigation 20 | 21 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 22 | if segue.identifier == "HorizontalSegue" { 23 | guard let destinationViewController = segue.destination as? ViewController else { return } 24 | destinationViewController.scrollingDirection = .left 25 | } else if segue.identifier == "VerticalSegue" { 26 | guard let destinationViewController = segue.destination as? ViewController else { return } 27 | destinationViewController.scrollingDirection = .down 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/ParallaxBackgroundDirection.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PBParallaxBackgroundDirection.swift 3 | // ParallaxBackgroundSwift 4 | // 5 | // Created by Justin Hall on 8/8/17. 6 | // Copyright © 2017 jhall. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | enum ParallaxBackgroundDirection: Int { 13 | case up = 0 14 | case down 15 | case right 16 | case left 17 | } 18 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/ParallaxScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PBMyScene.swift 3 | // ParallaxBackgroundSwift 4 | // 5 | // Created by Justin Hall on 8/8/17. 6 | // Copyright © 2017 jhall. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SpriteKit 11 | 12 | class ParallaxScene: SKScene { 13 | 14 | var parallaxBackground: ParallaxScrolling 15 | 16 | init(size: CGSize, scrollingDirection: ParallaxBackgroundDirection, startingSpeed: CGFloat, speedDecreaseFactor: CGFloat) { 17 | var images = [UIImage]() 18 | if scrollingDirection == .up || scrollingDirection == .down { 19 | images = [#imageLiteral(resourceName: "pForegroundVertical.png"), #imageLiteral(resourceName: "pMiddleVertical.png"), #imageLiteral(resourceName: "pBackgroundVertical.png")] 20 | } else { 21 | images = [#imageLiteral(resourceName: "pGraph.png"),#imageLiteral(resourceName: "pForegroundHorizontal.png"), #imageLiteral(resourceName: "pMiddleHorizontal.png"), #imageLiteral(resourceName: "pBackgroundHorizontal.png")] 22 | } 23 | 24 | self.parallaxBackground = ParallaxScrolling( 25 | backgroundImages: images, 26 | size: size, 27 | scrollingDirection: scrollingDirection, 28 | startingSpeed:startingSpeed, 29 | speedDecreaseFactor: speedDecreaseFactor)! 30 | 31 | super.init(size: size) 32 | 33 | self.addChild(parallaxBackground) 34 | } 35 | 36 | required init?(coder aDecoder: NSCoder) { 37 | fatalError("init(coder:) has not been implemented") 38 | } 39 | 40 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 41 | parallaxBackground.reverseMovementDirection() 42 | } 43 | 44 | override func update(_ currentTime: TimeInterval) { 45 | parallaxBackground.updateTime() 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/ParallaxScrolling.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PBParallaxScrolling.swift 3 | // ParallaxBackgroundSwift 4 | // 5 | // Created by Justin Hall on 8/8/17. 6 | // Copyright © 2017 jhall. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SpriteKit 11 | 12 | class ParallaxScrolling: SKSpriteNode { 13 | 14 | let flickeringAdjustment: CGFloat = 0.05 15 | 16 | var backgrounds: [SKSpriteNode] 17 | var clonedBackgrounds: [SKSpriteNode] 18 | var speeds: [CGFloat] 19 | var numberOfBackgrounds = 0 20 | var scrollingDirection: ParallaxBackgroundDirection 21 | 22 | init?(backgroundImages: [UIImage], size: CGSize, scrollingDirection: ParallaxBackgroundDirection, startingSpeed: CGFloat, speedDecreaseFactor: CGFloat) { 23 | self.backgrounds = [] 24 | self.clonedBackgrounds = [] 25 | self.speeds = [] 26 | self.numberOfBackgrounds = backgroundImages.count 27 | self.scrollingDirection = scrollingDirection 28 | super.init(texture: nil, color:UIColor.clear, size: size) 29 | 30 | let zPos = 1.0 / CGFloat(numberOfBackgrounds) 31 | var currentSpeed = startingSpeed 32 | self.position = CGPoint(x: self.size.width / 2, y: self.size.height / 2) 33 | self.zPosition = -100 34 | 35 | for (index, image) in backgroundImages.enumerated() { 36 | let background = SKSpriteNode(texture: SKTexture(cgImage: image.cgImage!), size:size) 37 | 38 | background.zPosition = self.zPosition - (zPos + (zPos * CGFloat(index))) 39 | background.position = CGPoint(x: 0.0, y: 0.0) 40 | guard let clonedBackground = background.copy() as? SKSpriteNode else { return } 41 | var clonedBackgroundX = background.position.x 42 | var clonedBackgroundY = background.position.y 43 | 44 | switch scrollingDirection { 45 | case .right: 46 | clonedBackgroundX = -background.size.width 47 | case .left: 48 | clonedBackgroundX = background.size.width 49 | case .up: 50 | clonedBackgroundY = -background.size.height 51 | case .down: 52 | clonedBackgroundY = background.size.height 53 | } 54 | 55 | clonedBackground.position = CGPoint(x: clonedBackgroundX,y: clonedBackgroundY) 56 | backgrounds.append(background) 57 | clonedBackgrounds.append(clonedBackground) 58 | speeds.append(currentSpeed) 59 | 60 | // Decrease speed 61 | currentSpeed = currentSpeed / speedDecreaseFactor 62 | 63 | // Add backgrounds as childs to this node 64 | self.addChild(background) 65 | self.addChild(clonedBackground) 66 | } 67 | } 68 | 69 | required init?(coder aDecoder: NSCoder) { 70 | fatalError("init(coder:) has not been implemented") 71 | } 72 | 73 | func reverseMovementDirection() { 74 | var newDirection: ParallaxBackgroundDirection = scrollingDirection 75 | switch scrollingDirection { 76 | case .down: 77 | newDirection = .up 78 | break 79 | case .up: 80 | newDirection = .down 81 | break 82 | case .left: 83 | newDirection = .right 84 | break 85 | case .right: 86 | newDirection = .left 87 | break 88 | } 89 | self.scrollingDirection = newDirection 90 | } 91 | 92 | func updateTime() { 93 | for i in 0..= background.size.width) { 109 | adjustedBackgroundX = adjustedBackgroundX - 2 * background.size.width + flickeringAdjustment 110 | } 111 | if (adjustedClonedBackgroundX >= clonedBackground.size.width) { 112 | adjustedClonedBackgroundX = adjustedClonedBackgroundX - 2 * clonedBackground.size.width + flickeringAdjustment 113 | } 114 | case .left: 115 | adjustedBackgroundX -= speed 116 | adjustedClonedBackgroundX -= speed 117 | 118 | if (adjustedBackgroundX <= -self.size.width) { 119 | adjustedBackgroundX = adjustedBackgroundX + 2 * self.size.width - flickeringAdjustment 120 | } 121 | if adjustedClonedBackgroundX <= -self.size.width { 122 | adjustedClonedBackgroundX = adjustedClonedBackgroundX + 2 * self.size.width - flickeringAdjustment 123 | } 124 | case .up: 125 | adjustedBackgroundY += speed 126 | adjustedBackgroundY += speed 127 | 128 | if adjustedBackgroundY >= background.size.height { 129 | adjustedBackgroundY = adjustedBackgroundY - 2 * background.size.height + flickeringAdjustment 130 | } 131 | if adjustedClonedBackgroundY >= clonedBackground.size.height { 132 | adjustedClonedBackgroundY = adjustedClonedBackgroundY - 2 * clonedBackground.size.height + flickeringAdjustment 133 | } 134 | case .down: 135 | adjustedBackgroundY -= speed // need to just be minus 136 | adjustedClonedBackgroundY -= speed // need to just be minus? 137 | 138 | if (adjustedBackgroundY <= -self.size.height) { 139 | adjustedBackgroundY = adjustedBackgroundY + 2 * self.size.height - flickeringAdjustment 140 | } 141 | if adjustedClonedBackgroundY <= -self.size.height { 142 | adjustedClonedBackgroundY = adjustedClonedBackgroundY + 2 * self.size.height - flickeringAdjustment 143 | } 144 | } 145 | background.position = CGPoint(x: adjustedBackgroundX, y: adjustedBackgroundY) 146 | clonedBackground.position = CGPoint(x: adjustedClonedBackgroundX, y: adjustedClonedBackgroundY) 147 | } 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ParallaxBackgroundSwift 4 | // 5 | // Created by Justin Hall on 8/8/17. 6 | // Copyright © 2017 jhall. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SpriteKit 11 | 12 | class ViewController: UIViewController { 13 | 14 | var scrollingDirection: ParallaxBackgroundDirection? 15 | 16 | override func viewWillLayoutSubviews() { 17 | super.viewDidLoad() 18 | let skView = self.view as! SKView 19 | skView.ignoresSiblingOrder = true 20 | skView.showsFPS = true 21 | guard let direction = scrollingDirection else { return } 22 | 23 | let scene = ParallaxScene( 24 | size: skView.bounds.size, 25 | scrollingDirection: direction, 26 | startingSpeed: 4.0, // change this to increase/decrease overall speed 27 | speedDecreaseFactor: 2.2) // change this increase/decrease speed decrease between layers 28 | scene.scaleMode = .aspectFit 29 | 30 | skView.presentScene(scene) 31 | } 32 | 33 | override var shouldAutorotate: Bool { return true } 34 | override var prefersStatusBarHidden: Bool { return true } 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pBackgroundHorizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pBackgroundHorizontal.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pBackgroundHorizontal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pBackgroundHorizontal@2x.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pBackgroundVertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pBackgroundVertical.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pBackgroundVertical@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pBackgroundVertical@2x.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pForegroundHorizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pForegroundHorizontal.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pForegroundHorizontal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pForegroundHorizontal@2x.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pForegroundVertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pForegroundVertical.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pForegroundVertical@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pForegroundVertical@2x.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pGraph@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pGraph@2x.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pGraph@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pGraph@3x.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pMiddleHorizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pMiddleHorizontal.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pMiddleHorizontal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pMiddleHorizontal@2x.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pMiddleVertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pMiddleVertical.png -------------------------------------------------------------------------------- /ParallaxBackgroundSwift/pMiddleVertical@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/ParallaxBackgroundSwift/pMiddleVertical@2x.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS Parallax Demo ## Description Demo app using Apple's Spritekit to create a nice Parallax effect. Written in Swift. ## License The MIT License (MIT) Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files (the "Software") to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /parralax.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dogtownmedia/ios-parallax-demo/b6207c367754af1c126d55ab2a461feffe8303b2/parralax.gif --------------------------------------------------------------------------------