iOS Developer Library

Developer

UIKit Framework Reference UIInterpolatingMotionEffect Class Reference

Options
Deployment Target:

On This Page
Language:

UIInterpolatingMotionEffect

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 7.0 and later.

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.

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

    Declaration

    Swift

    init(keyPath keyPath: String, type type: UIInterpolatingMotionEffectType)

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • keyPath keyPath Property

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

    Declaration

    Swift

    var keyPath: String { get }

    Objective-C

    @property(readonly, nonatomic) NSString *keyPath

    Discussion

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

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • type type Property

    The tilt direction to monitor. (read-only)

    Declaration

    Swift

    var type: UIInterpolatingMotionEffectType { get }

    Objective-C

    @property(readonly, nonatomic) UIInterpolatingMotionEffectType type

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • The value that maps to the minimum viewer offset.

    Declaration

    Swift

    var minimumRelativeValue: AnyObject!

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • The value that maps to the maximum viewer offset.

    Declaration

    Swift

    var maximumRelativeValue: AnyObject!

    Objective-C

    @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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • The axis to use when interpolating values.

    Declaration

    Swift

    enum UIInterpolatingMotionEffectType : Int { case TiltAlongHorizontalAxis case TiltAlongVerticalAxis }

    Objective-C

    typedef enum { UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis, UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis } UIInterpolatingMotionEffectType;

    Constants

    • TiltAlongHorizontalAxis

      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.

    • TiltAlongVerticalAxis

      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.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.