iOS Guides | Samples

MonoTouch.UIKit.UIInterpolatingMotionEffect Class

A UIMotionEffect that maps the device vertical and horizontal tilt into values on a keypath.

See Also: UIInterpolatingMotionEffect


[MonoTouch.Foundation.Register("UIInterpolatingMotionEffect", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 7, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
public class UIInterpolatingMotionEffect : UIMotionEffect, IDisposable


Objects of the instance UIInterpolatingMotionEffect take the values of the hardware tilt and map those into a range (specified by the properties MinimumRelativeValue and MaximumRelativeValue) and then it applies that to the property referenced by the keypath.

The delta computed is then applied to the property.

The following example adds two square views, a reference one, and a semi-transparent one that has two interpolating motion effect handlers, one for the center.X position and one for center.y.

C# Example

class MotionSquareViewController : UIViewController {
	public MotionSquareViewController () : base() {

	public override void ViewDidLoad ()
		var reference = new UIView (new RectangleF (110, 110, 90, 90)) {
			BackgroundColor =  UIColor.Blue
		var tracking = new UIView (new RectangleF (100, 100, 100, 100)) {
			BackgroundColor =  UIColor.FromRGBA (.5f, .5f, .5f, .5f)
		View.AddSubviews (reference, tracking);
		var mx = new UIInterpolatingMotionEffect ("center.x", UIInterpolatingMotionEffectType.TiltAlongHorizontalAxis) {
			MinimumRelativeValue = new NSNumber (-100),
			MaximumRelativeValue = new NSNumber (100)
		var my = new UIInterpolatingMotionEffect ("center.y", UIInterpolatingMotionEffectType.TiltAlongVerticalAxis) {
			MinimumRelativeValue = new NSNumber (-100),
			MaximumRelativeValue = new NSNumber (100)
		tracking.AddMotionEffect (mx);
		tracking.AddMotionEffect (my);

Related content


Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions:

The members of MonoTouch.UIKit.UIInterpolatingMotionEffect are listed below.

See Also: UIMotionEffect

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

ClassHandleIntPtr. The handle for this class.
KeyPathString. An animatable property on the UIView to which the effect should be applied.
MaximumRelativeValueNSObject. The maximum value for the UIInterpolatingMotionEffect.KeyPath.
MinimumRelativeValueNSObject. The minimum value for the UIInterpolatingMotionEffect.KeyPath.
TypeUIInterpolatingMotionEffectType. The tilt direction being monitored.