UIKit.UIDynamicAnimator Class
Coordinates the UIKit Dynamics of a set of UIKit.IUIDynamicItems and UIKit.UIDynamicBehaviors.

See Also: UIDynamicAnimator Members

Syntax

[Foundation.Register("UIDynamicAnimator", true)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_7_0)]
public class UIDynamicAnimator : Foundation.NSObject, IEnumerable<UIDynamicBehavior>

Remarks

The dynamic animator is responsible for coordinating physics simulations attached to a UIView. These physics simulations are implemented as subclasses of the UIKit.UIDynamicBehavior class, and include various predefined simulations for gravity, collision detection, attaching, snapping, forces and controling item properties.

UIKit.UIDynamicAnimator It provides the overall context for managing the physics simulation attached to a UIView. Additionally, it defines the coordinate system for the dynamics and wraps the underlying animation engine. Finally, it keeps track of the UIKit.UIDynamicBehaviors and UIKit.IUIDynamicItems that define the particular behaviors and items for which dynamics are desired.

Adding behaviors to a dynamic animator will cause the behavior to run as part of the physics simulation that UIKit runs. To stop a behavior from running (and be part of the simulation), you must remove the behavior from the dynamic animator (use UIDynamicAnimator.RemoveBehavior or UIDynamicAnimator.RemoveAllBehaviors.

It is the application developer's responsibility to create a configuration that can be solved by the physics-like behavior of UI Dynamics.

The following example shows how you can add a couple of behaviors to an animator:

C# Example

public override void ViewDidLoad ()
{
	base.ViewDidLoad ();

	// Create a dynamic animator for the specified UIView
	// in this case, the property "View" of UIViewController
	//
	animator = new UIDynamicAnimator (View);
	
	// Creates two dynamic behaviors

	// Create a gravity behavior that operates on the `square' UIView
	var gravityBehavior = new UIGravityBehavior (square);

	// Create a collision behavior that operates on the same `square' UIVew
	var collisionBehavior = new UICollisionBehavior (square) {
		TranslatesReferenceBoundsIntoBoundary = true
	};

	// Detect collision, hook up to the events raised by that behavior
	collisionBehavior.BeganBoundaryContact += BeganContact;
	collisionBehavior.EndedBoundaryContact += EndedContact;

	// Add the two behaviors to the dynamic animator
	animator.AddBehaviors (gravityBehavior, collisionBehavior);

	// The simulation will start running
}

These are the predefined behaviors that extend the UIKit.UIDynamicBehavior class: UIKit.UIAttachmentBehavior, UIKit.UICollisionBehavior, UIKit.UIDynamicItemBehavior, UIKit.UIGravityBehavior, UIKit.UIPushBehavior and UIKit.UISnapBehavior.

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0