├── .gitignore ├── AccelerometerParallaxExample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── AccelerometerParallaxExample ├── AccelerometerParallaxExampleApp.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ └── shot.imageset │ │ ├── Contents.json │ │ └── shot.png ├── ContentView.swift ├── MotionManager.swift ├── ParallaxMotionModifier.swift └── Preview Content │ └── Preview Assets.xcassets │ └── Contents.json ├── README.md └── output.gif /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Xcode 4 | # 5 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 6 | 7 | ## User settings 8 | xcuserdata/ 9 | 10 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 11 | *.xcscmblueprint 12 | *.xccheckout 13 | 14 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 15 | build/ 16 | DerivedData/ 17 | *.moved-aside 18 | *.pbxuser 19 | !default.pbxuser 20 | *.mode1v3 21 | !default.mode1v3 22 | *.mode2v3 23 | !default.mode2v3 24 | *.perspectivev3 25 | !default.perspectivev3 26 | 27 | ## Obj-C/Swift specific 28 | *.hmap 29 | 30 | ## App packaging 31 | *.ipa 32 | *.dSYM.zip 33 | *.dSYM 34 | 35 | ## Playgrounds 36 | timeline.xctimeline 37 | playground.xcworkspace 38 | 39 | # Swift Package Manager 40 | # 41 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 42 | # Packages/ 43 | # Package.pins 44 | # Package.resolved 45 | # *.xcodeproj 46 | # 47 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 48 | # hence it is not needed unless you have added a package configuration file to your project 49 | # .swiftpm 50 | 51 | .build/ 52 | 53 | # CocoaPods 54 | # 55 | # We recommend against adding the Pods directory to your .gitignore. However 56 | # you should judge for yourself, the pros and cons are mentioned at: 57 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 58 | # 59 | # Pods/ 60 | # 61 | # Add this line if you want to avoid checking in source code from the Xcode workspace 62 | # *.xcworkspace 63 | 64 | # Carthage 65 | # 66 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 67 | # Carthage/Checkouts 68 | 69 | Carthage/Build/ 70 | 71 | # Accio dependency management 72 | Dependencies/ 73 | .accio/ 74 | 75 | # fastlane 76 | # 77 | # It is recommended to not store the screenshots in the git repo. 78 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 79 | # For more information about the recommended setup visit: 80 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 81 | 82 | fastlane/report.xml 83 | fastlane/Preview.html 84 | fastlane/screenshots/**/*.png 85 | fastlane/test_output 86 | 87 | # Code Injection 88 | # 89 | # After new code Injection tools there's a generated folder /iOSInjectionProject 90 | # https://github.com/johnno1962/injectionforxcode 91 | 92 | iOSInjectionProject/ 93 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A0E6D09627D9F9A900A3F340 /* AccelerometerParallaxExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E6D09527D9F9A900A3F340 /* AccelerometerParallaxExampleApp.swift */; }; 11 | A0E6D09827D9F9A900A3F340 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E6D09727D9F9A900A3F340 /* ContentView.swift */; }; 12 | A0E6D09A27D9F9AA00A3F340 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A0E6D09927D9F9AA00A3F340 /* Assets.xcassets */; }; 13 | A0E6D09D27D9F9AA00A3F340 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A0E6D09C27D9F9AA00A3F340 /* Preview Assets.xcassets */; }; 14 | A0E6D0A427D9FA0100A3F340 /* ParallaxMotionModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E6D0A327D9FA0100A3F340 /* ParallaxMotionModifier.swift */; }; 15 | A0E6D0A627D9FA0800A3F340 /* MotionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0E6D0A527D9FA0800A3F340 /* MotionManager.swift */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXFileReference section */ 19 | A0E6D09227D9F9A900A3F340 /* AccelerometerParallaxExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AccelerometerParallaxExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 20 | A0E6D09527D9F9A900A3F340 /* AccelerometerParallaxExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccelerometerParallaxExampleApp.swift; sourceTree = ""; }; 21 | A0E6D09727D9F9A900A3F340 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 22 | A0E6D09927D9F9AA00A3F340 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 23 | A0E6D09C27D9F9AA00A3F340 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 24 | A0E6D0A327D9FA0100A3F340 /* ParallaxMotionModifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ParallaxMotionModifier.swift; sourceTree = ""; }; 25 | A0E6D0A527D9FA0800A3F340 /* MotionManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionManager.swift; sourceTree = ""; }; 26 | /* End PBXFileReference section */ 27 | 28 | /* Begin PBXFrameworksBuildPhase section */ 29 | A0E6D08F27D9F9A900A3F340 /* Frameworks */ = { 30 | isa = PBXFrameworksBuildPhase; 31 | buildActionMask = 2147483647; 32 | files = ( 33 | ); 34 | runOnlyForDeploymentPostprocessing = 0; 35 | }; 36 | /* End PBXFrameworksBuildPhase section */ 37 | 38 | /* Begin PBXGroup section */ 39 | A0E6D08927D9F9A900A3F340 = { 40 | isa = PBXGroup; 41 | children = ( 42 | A0E6D09427D9F9A900A3F340 /* AccelerometerParallaxExample */, 43 | A0E6D09327D9F9A900A3F340 /* Products */, 44 | ); 45 | sourceTree = ""; 46 | }; 47 | A0E6D09327D9F9A900A3F340 /* Products */ = { 48 | isa = PBXGroup; 49 | children = ( 50 | A0E6D09227D9F9A900A3F340 /* AccelerometerParallaxExample.app */, 51 | ); 52 | name = Products; 53 | sourceTree = ""; 54 | }; 55 | A0E6D09427D9F9A900A3F340 /* AccelerometerParallaxExample */ = { 56 | isa = PBXGroup; 57 | children = ( 58 | A0E6D09527D9F9A900A3F340 /* AccelerometerParallaxExampleApp.swift */, 59 | A0E6D09727D9F9A900A3F340 /* ContentView.swift */, 60 | A0E6D0A327D9FA0100A3F340 /* ParallaxMotionModifier.swift */, 61 | A0E6D0A527D9FA0800A3F340 /* MotionManager.swift */, 62 | A0E6D09927D9F9AA00A3F340 /* Assets.xcassets */, 63 | A0E6D09B27D9F9AA00A3F340 /* Preview Content */, 64 | ); 65 | path = AccelerometerParallaxExample; 66 | sourceTree = ""; 67 | }; 68 | A0E6D09B27D9F9AA00A3F340 /* Preview Content */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | A0E6D09C27D9F9AA00A3F340 /* Preview Assets.xcassets */, 72 | ); 73 | path = "Preview Content"; 74 | sourceTree = ""; 75 | }; 76 | /* End PBXGroup section */ 77 | 78 | /* Begin PBXNativeTarget section */ 79 | A0E6D09127D9F9A900A3F340 /* AccelerometerParallaxExample */ = { 80 | isa = PBXNativeTarget; 81 | buildConfigurationList = A0E6D0A027D9F9AA00A3F340 /* Build configuration list for PBXNativeTarget "AccelerometerParallaxExample" */; 82 | buildPhases = ( 83 | A0E6D08E27D9F9A900A3F340 /* Sources */, 84 | A0E6D08F27D9F9A900A3F340 /* Frameworks */, 85 | A0E6D09027D9F9A900A3F340 /* Resources */, 86 | ); 87 | buildRules = ( 88 | ); 89 | dependencies = ( 90 | ); 91 | name = AccelerometerParallaxExample; 92 | productName = AccelerometerParallaxExample; 93 | productReference = A0E6D09227D9F9A900A3F340 /* AccelerometerParallaxExample.app */; 94 | productType = "com.apple.product-type.application"; 95 | }; 96 | /* End PBXNativeTarget section */ 97 | 98 | /* Begin PBXProject section */ 99 | A0E6D08A27D9F9A900A3F340 /* Project object */ = { 100 | isa = PBXProject; 101 | attributes = { 102 | BuildIndependentTargetsInParallel = 1; 103 | LastSwiftUpdateCheck = 1320; 104 | LastUpgradeCheck = 1320; 105 | TargetAttributes = { 106 | A0E6D09127D9F9A900A3F340 = { 107 | CreatedOnToolsVersion = 13.2.1; 108 | }; 109 | }; 110 | }; 111 | buildConfigurationList = A0E6D08D27D9F9A900A3F340 /* Build configuration list for PBXProject "AccelerometerParallaxExample" */; 112 | compatibilityVersion = "Xcode 13.0"; 113 | developmentRegion = en; 114 | hasScannedForEncodings = 0; 115 | knownRegions = ( 116 | en, 117 | Base, 118 | ); 119 | mainGroup = A0E6D08927D9F9A900A3F340; 120 | productRefGroup = A0E6D09327D9F9A900A3F340 /* Products */; 121 | projectDirPath = ""; 122 | projectRoot = ""; 123 | targets = ( 124 | A0E6D09127D9F9A900A3F340 /* AccelerometerParallaxExample */, 125 | ); 126 | }; 127 | /* End PBXProject section */ 128 | 129 | /* Begin PBXResourcesBuildPhase section */ 130 | A0E6D09027D9F9A900A3F340 /* Resources */ = { 131 | isa = PBXResourcesBuildPhase; 132 | buildActionMask = 2147483647; 133 | files = ( 134 | A0E6D09D27D9F9AA00A3F340 /* Preview Assets.xcassets in Resources */, 135 | A0E6D09A27D9F9AA00A3F340 /* Assets.xcassets in Resources */, 136 | ); 137 | runOnlyForDeploymentPostprocessing = 0; 138 | }; 139 | /* End PBXResourcesBuildPhase section */ 140 | 141 | /* Begin PBXSourcesBuildPhase section */ 142 | A0E6D08E27D9F9A900A3F340 /* Sources */ = { 143 | isa = PBXSourcesBuildPhase; 144 | buildActionMask = 2147483647; 145 | files = ( 146 | A0E6D09827D9F9A900A3F340 /* ContentView.swift in Sources */, 147 | A0E6D0A427D9FA0100A3F340 /* ParallaxMotionModifier.swift in Sources */, 148 | A0E6D09627D9F9A900A3F340 /* AccelerometerParallaxExampleApp.swift in Sources */, 149 | A0E6D0A627D9FA0800A3F340 /* MotionManager.swift in Sources */, 150 | ); 151 | runOnlyForDeploymentPostprocessing = 0; 152 | }; 153 | /* End PBXSourcesBuildPhase section */ 154 | 155 | /* Begin XCBuildConfiguration section */ 156 | A0E6D09E27D9F9AA00A3F340 /* Debug */ = { 157 | isa = XCBuildConfiguration; 158 | buildSettings = { 159 | ALWAYS_SEARCH_USER_PATHS = NO; 160 | CLANG_ANALYZER_NONNULL = YES; 161 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 162 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 163 | CLANG_CXX_LIBRARY = "libc++"; 164 | CLANG_ENABLE_MODULES = YES; 165 | CLANG_ENABLE_OBJC_ARC = YES; 166 | CLANG_ENABLE_OBJC_WEAK = YES; 167 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 168 | CLANG_WARN_BOOL_CONVERSION = YES; 169 | CLANG_WARN_COMMA = YES; 170 | CLANG_WARN_CONSTANT_CONVERSION = YES; 171 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 172 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 173 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 174 | CLANG_WARN_EMPTY_BODY = YES; 175 | CLANG_WARN_ENUM_CONVERSION = YES; 176 | CLANG_WARN_INFINITE_RECURSION = YES; 177 | CLANG_WARN_INT_CONVERSION = YES; 178 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 179 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 180 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 181 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 182 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 183 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 184 | CLANG_WARN_STRICT_PROTOTYPES = YES; 185 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 186 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 187 | CLANG_WARN_UNREACHABLE_CODE = YES; 188 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 189 | COPY_PHASE_STRIP = NO; 190 | DEBUG_INFORMATION_FORMAT = dwarf; 191 | ENABLE_STRICT_OBJC_MSGSEND = YES; 192 | ENABLE_TESTABILITY = YES; 193 | GCC_C_LANGUAGE_STANDARD = gnu11; 194 | GCC_DYNAMIC_NO_PIC = NO; 195 | GCC_NO_COMMON_BLOCKS = YES; 196 | GCC_OPTIMIZATION_LEVEL = 0; 197 | GCC_PREPROCESSOR_DEFINITIONS = ( 198 | "DEBUG=1", 199 | "$(inherited)", 200 | ); 201 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 202 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 203 | GCC_WARN_UNDECLARED_SELECTOR = YES; 204 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 205 | GCC_WARN_UNUSED_FUNCTION = YES; 206 | GCC_WARN_UNUSED_VARIABLE = YES; 207 | IPHONEOS_DEPLOYMENT_TARGET = 15.2; 208 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 209 | MTL_FAST_MATH = YES; 210 | ONLY_ACTIVE_ARCH = YES; 211 | SDKROOT = iphoneos; 212 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 213 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 214 | }; 215 | name = Debug; 216 | }; 217 | A0E6D09F27D9F9AA00A3F340 /* Release */ = { 218 | isa = XCBuildConfiguration; 219 | buildSettings = { 220 | ALWAYS_SEARCH_USER_PATHS = NO; 221 | CLANG_ANALYZER_NONNULL = YES; 222 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 223 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 224 | CLANG_CXX_LIBRARY = "libc++"; 225 | CLANG_ENABLE_MODULES = YES; 226 | CLANG_ENABLE_OBJC_ARC = YES; 227 | CLANG_ENABLE_OBJC_WEAK = YES; 228 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 229 | CLANG_WARN_BOOL_CONVERSION = YES; 230 | CLANG_WARN_COMMA = YES; 231 | CLANG_WARN_CONSTANT_CONVERSION = YES; 232 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 233 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 234 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 235 | CLANG_WARN_EMPTY_BODY = YES; 236 | CLANG_WARN_ENUM_CONVERSION = YES; 237 | CLANG_WARN_INFINITE_RECURSION = YES; 238 | CLANG_WARN_INT_CONVERSION = YES; 239 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 240 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 241 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 242 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 243 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 244 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 245 | CLANG_WARN_STRICT_PROTOTYPES = YES; 246 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 247 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 248 | CLANG_WARN_UNREACHABLE_CODE = YES; 249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 250 | COPY_PHASE_STRIP = NO; 251 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 252 | ENABLE_NS_ASSERTIONS = NO; 253 | ENABLE_STRICT_OBJC_MSGSEND = YES; 254 | GCC_C_LANGUAGE_STANDARD = gnu11; 255 | GCC_NO_COMMON_BLOCKS = YES; 256 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 257 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 258 | GCC_WARN_UNDECLARED_SELECTOR = YES; 259 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 260 | GCC_WARN_UNUSED_FUNCTION = YES; 261 | GCC_WARN_UNUSED_VARIABLE = YES; 262 | IPHONEOS_DEPLOYMENT_TARGET = 15.2; 263 | MTL_ENABLE_DEBUG_INFO = NO; 264 | MTL_FAST_MATH = YES; 265 | SDKROOT = iphoneos; 266 | SWIFT_COMPILATION_MODE = wholemodule; 267 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 268 | VALIDATE_PRODUCT = YES; 269 | }; 270 | name = Release; 271 | }; 272 | A0E6D0A127D9F9AA00A3F340 /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 276 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 277 | CODE_SIGN_STYLE = Automatic; 278 | CURRENT_PROJECT_VERSION = 1; 279 | DEVELOPMENT_ASSET_PATHS = "\"AccelerometerParallaxExample/Preview Content\""; 280 | DEVELOPMENT_TEAM = 4AW3ZWSN4J; 281 | ENABLE_PREVIEWS = YES; 282 | GENERATE_INFOPLIST_FILE = YES; 283 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 284 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 285 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 286 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 287 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 288 | LD_RUNPATH_SEARCH_PATHS = ( 289 | "$(inherited)", 290 | "@executable_path/Frameworks", 291 | ); 292 | MARKETING_VERSION = 1.0; 293 | PRODUCT_BUNDLE_IDENTIFIER = me.stereocat.AccelerometerParallaxExample; 294 | PRODUCT_NAME = "$(TARGET_NAME)"; 295 | SWIFT_EMIT_LOC_STRINGS = YES; 296 | SWIFT_VERSION = 5.0; 297 | TARGETED_DEVICE_FAMILY = "1,2"; 298 | }; 299 | name = Debug; 300 | }; 301 | A0E6D0A227D9F9AA00A3F340 /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 305 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 306 | CODE_SIGN_STYLE = Automatic; 307 | CURRENT_PROJECT_VERSION = 1; 308 | DEVELOPMENT_ASSET_PATHS = "\"AccelerometerParallaxExample/Preview Content\""; 309 | DEVELOPMENT_TEAM = 4AW3ZWSN4J; 310 | ENABLE_PREVIEWS = YES; 311 | GENERATE_INFOPLIST_FILE = YES; 312 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 313 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 314 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 315 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 316 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 317 | LD_RUNPATH_SEARCH_PATHS = ( 318 | "$(inherited)", 319 | "@executable_path/Frameworks", 320 | ); 321 | MARKETING_VERSION = 1.0; 322 | PRODUCT_BUNDLE_IDENTIFIER = me.stereocat.AccelerometerParallaxExample; 323 | PRODUCT_NAME = "$(TARGET_NAME)"; 324 | SWIFT_EMIT_LOC_STRINGS = YES; 325 | SWIFT_VERSION = 5.0; 326 | TARGETED_DEVICE_FAMILY = "1,2"; 327 | }; 328 | name = Release; 329 | }; 330 | /* End XCBuildConfiguration section */ 331 | 332 | /* Begin XCConfigurationList section */ 333 | A0E6D08D27D9F9A900A3F340 /* Build configuration list for PBXProject "AccelerometerParallaxExample" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | A0E6D09E27D9F9AA00A3F340 /* Debug */, 337 | A0E6D09F27D9F9AA00A3F340 /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | A0E6D0A027D9F9AA00A3F340 /* Build configuration list for PBXNativeTarget "AccelerometerParallaxExample" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | A0E6D0A127D9F9AA00A3F340 /* Debug */, 346 | A0E6D0A227D9F9AA00A3F340 /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | /* End XCConfigurationList section */ 352 | }; 353 | rootObject = A0E6D08A27D9F9A900A3F340 /* Project object */; 354 | } 355 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/AccelerometerParallaxExampleApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AccelerometerParallaxExampleApp.swift 3 | // AccelerometerParallaxExample 4 | // 5 | // Created by Dmitry Shlyugaev on 10.03.2022. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct AccelerometerParallaxExampleApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/Assets.xcassets/shot.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "shot.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/Assets.xcassets/shot.imageset/shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmitryshliugaev/swiftui-accelerometer-parallax-example/3e57d65696350d9211027cd33eb9e00ebe999af1/AccelerometerParallaxExample/Assets.xcassets/shot.imageset/shot.png -------------------------------------------------------------------------------- /AccelerometerParallaxExample/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // AccelerometerParallaxExample 4 | // 5 | // Created by Dmitry Shlyugaev on 10.03.2022. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | 12 | @ObservedObject var manager = MotionManager() 13 | 14 | var Photo: some View = Image("shot") 15 | .resizable() 16 | .aspectRatio(contentMode: .fit) 17 | 18 | 19 | var body: some View { 20 | ZStack(alignment: .center) { 21 | Color.white 22 | 23 | Photo 24 | .cornerRadius(32) 25 | .blur(radius: 5) 26 | .offset(y: 10) 27 | .opacity(0.9) 28 | .frame(width: UIScreen.main.bounds.width - 100) 29 | .overlay(Photo 30 | .cornerRadius(12) 31 | .modifier(ParallaxMotionModifier(manager: manager, magnitude: 30))) 32 | } 33 | } 34 | } 35 | 36 | struct ContentView_Previews: PreviewProvider { 37 | static var previews: some View { 38 | ContentView() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/MotionManager.swift: -------------------------------------------------------------------------------- 1 | /* 2 | from tutorial https://trailingclosure.com/device-motion-effect/ 3 | */ 4 | 5 | import CoreMotion 6 | 7 | class MotionManager: ObservableObject { 8 | 9 | @Published var pitch: Double = 0.0 10 | @Published var roll: Double = 0.0 11 | 12 | private var manager: CMMotionManager 13 | 14 | init() { 15 | self.manager = CMMotionManager() 16 | self.manager.deviceMotionUpdateInterval = 1/60 17 | self.manager.startDeviceMotionUpdates(to: .main) { (motionData, error) in 18 | if let error = error { 19 | debugPrint(error) 20 | return 21 | } 22 | 23 | if let motionData = motionData { 24 | self.pitch = motionData.attitude.pitch 25 | self.roll = motionData.attitude.roll 26 | } 27 | } 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/ParallaxMotionModifier.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParallaxMotionModifier.swift 3 | // AccelerometerParallaxExample 4 | // 5 | // Created by Dmitry Shlyugaev on 10.03.2022. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ParallaxMotionModifier: ViewModifier { 11 | 12 | @ObservedObject var manager: MotionManager 13 | var magnitude: Double 14 | 15 | func body(content: Content) -> some View { 16 | content 17 | .shadow(color: .black.opacity(0.2), 18 | radius: 32, 19 | x: -CGFloat(manager.roll * magnitude), 20 | y: -CGFloat(manager.pitch * magnitude)) 21 | .offset(x: CGFloat(manager.roll * magnitude), 22 | y: CGFloat(manager.pitch * magnitude)) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /AccelerometerParallaxExample/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![path](output.gif) -------------------------------------------------------------------------------- /output.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dmitryshliugaev/swiftui-accelerometer-parallax-example/3e57d65696350d9211027cd33eb9e00ebe999af1/output.gif --------------------------------------------------------------------------------