---
title: UIMotionEffect
framework: uikit
role: symbol
role_heading: Class
path: uikit/uimotioneffect
---

# UIMotionEffect

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

## Declaration

```swift
@MainActor class UIMotionEffect
```

## Overview

Overview Subclasses of UIMotionEffect are responsible for defining the behavior to apply to a view when motion is detected. They do this by overriding the 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 class to implement effects or you can subclass and implement your own effects. If you subclass, your subclass must conform to the NSCopying and NSCoding protocols and must implement the keyPathsAndRelativeValues(forViewerOffset:) method.

## Topics

### Initializing a motion effect

- [init()](uikit/uimotioneffect/init().md)
- [init(coder:)](uikit/uimotioneffect/init(coder:).md)

### Getting the key paths

- [keyPathsAndRelativeValues(forViewerOffset:)](uikit/uimotioneffect/keypathsandrelativevalues(forvieweroffset:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [UIInterpolatingMotionEffect](uikit/uiinterpolatingmotioneffect.md)
- [UIMotionEffectGroup](uikit/uimotioneffectgroup.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
