UIInterpolatingMotionEffect Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 7.0 and later.
Declared in
UIMotionEffect.h

Overview

A UIInterpolatingMotionEffect object maps the horizontal or vertical tilt of a device to values that you specify so that UIKit can apply those values to your views. You use this class to determine the amount of tilt along a single axis to apply to a view.

After creating an instance of this class, you must assign appropriate values to the minimumRelativeValue and maximumRelativeValue properties. As the user moves the device, the motion effect object translates the fixed offset values returned by the system (which are in the range -1 to 1) to the range of values you specified. UIKit then applies the translated values to any target views.

Tasks

Initializing a Motion Effect

Accessing the Motion Attributes

Properties

keyPath

The key path you want to modify on the view. (read-only)

@property (readonly, nonatomic) NSString *keyPath;
Discussion

This property must correspond to an animatable property of the view to which the motion effect is attached.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIMotionEffect.h

maximumRelativeValue

The value that maps to the maximum viewer offset.

@property (retain, nonatomic) id maximumRelativeValue;
Discussion

The value in this property is the value returned when the viewer offset value along the given axis is 1.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIMotionEffect.h

minimumRelativeValue

The value that maps to the minimum viewer offset.

@property (retain, nonatomic) id minimumRelativeValue;
Discussion

The value in this property is the value returned when the viewer offset value along the given axis is -1.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIMotionEffect.h

type

The tilt direction to monitor. (read-only)

@property (readonly, nonatomic) UIInterpolatingMotionEffectType type;
Availability
  • Available in iOS 7.0 and later.
Declared In
UIMotionEffect.h

Instance Methods

initWithKeyPath:type:

Initializes and returns an interpolating motion effect object configured for the specific tilt direction.

- (instancetype)initWithKeyPath:(NSString *)keyPath type:(UIInterpolatingMotionEffectType)type
Parameters
keyPath

The key path of the view that you want to modify. This path must correspond to an animatable property of the view on which this motion effect is applied. For example, to update the center property of the view, specify the string “center”.

type

The type of motion to track. You can track horizontal or vertical tilt. For a list of possible values, see “UIInterpolatingMotionEffectType”.

Return Value

An initialized interpolating motion effect object.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIMotionEffect.h

Constants

UIInterpolatingMotionEffectType

The axis to use when interpolating values.

typedef enum {
   UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis,
   UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis
} UIInterpolatingMotionEffectType;
Constants
UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis

Interpolate values along the horizontal axis, which involves the device facing left or right of the user’s viewpoint.

Available in iOS 7.0 and later.

Declared in UIMotionEffect.h.

UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis

Interpolate values along the vertical axis, which involves the device facing above or below the user’s viewpoint.

Available in iOS 7.0 and later.

Declared in UIMotionEffect.h.