<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIMotionEffect",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIMotionEffect"
  },
  "title" : "UIMotionEffect"
}
-->

# UIMotionEffect

An abstract superclass for defining motion-based modifiers for views.

```
@MainActor class UIMotionEffect
```

## Overview

Subclasses of [`UIMotionEffect`](/documentation/UIKit/UIMotionEffect) are responsible for defining the behavior to apply to a view when motion is detected. They do this by overriding the [`keyPathsAndRelativeValues(forViewerOffset:)`](/documentation/UIKit/UIMotionEffect/keyPathsAndRelativeValues(forViewerOffset:)) method and returning one or more key paths representing the view properties to modify.

### Subclassing notes

This class is abstract and can’t be instantiated directly. You can use the [`UIInterpolatingMotionEffect`](/documentation/UIKit/UIInterpolatingMotionEffect) class to implement effects or you can subclass and implement your own effects. If you subclass, your subclass must conform to the <doc://com.apple.documentation/documentation/Foundation/NSCopying> and <doc://com.apple.documentation/documentation/Foundation/NSCoding> protocols and must implement the [`keyPathsAndRelativeValues(forViewerOffset:)`](/documentation/UIKit/UIMotionEffect/keyPathsAndRelativeValues(forViewerOffset:)) method.

## Topics

### Initializing a motion effect

[`-  init`](/documentation/UIKit/UIMotionEffect/init())

Initializes the motion effect to its default state.

[`-  initWithCoder:`](/documentation/UIKit/UIMotionEffect/init(coder:))

Creates a motion effect from data in an unarchiver.

### Getting the key paths

[`-  keyPathsAndRelativeValuesForViewerOffset:`](/documentation/UIKit/UIMotionEffect/keyPathsAndRelativeValues(forViewerOffset:))

For a given set of offset values, returns the view properties (and corresponding values) to update.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Hashable`](/documentation/Swift/Hashable)

### Inherited By

[`UIMotionEffectGroup`](/documentation/UIKit/UIMotionEffectGroup)

[`UIInterpolatingMotionEffect`](/documentation/UIKit/UIInterpolatingMotionEffect)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)