iOS Guides | Samples

CoreAnimation.CABasicAnimation Class

Single keyframe based animations.

See Also: CABasicAnimation

Syntax

[Foundation.Register("CABasicAnimation", true)]
public class CABasicAnimation : CAPropertyAnimation

Remarks

The animation is created by calling the CABasicAnimation.FromKeyPath method and providing a keyPath that identifies the property on the target that will be animated. The animation is performed by using the values on the From, To and By properties applied to the keyPath.

The interpolation will depend on the values that you choose to set for From, To and By.  The following table shows the effects of setting one or more of those properites on the property referenced by the key path:

SettingsResult
No values are setInterpolates between old value and new value in the presentation layer.
From is setInterpolation is done from the From value to the current value in the presentation layer.
To is setInterpolation is done from the current value in the presentation layer to the To value.
By is setInterpolation is done between the current value on the presentation layer to the current value plus the value in By.
From and To are setInterpolation is done between the From and To values.
From and By are setInterpolation is done between the value set in From to From plus By.
To and By are setInterpolation is done between To minus By and By.

The From, To and By properties all take NSObject parameters. If you need to specify other parameters, like a CGColor, you can use the methods that take INativeObject parameters (GetByAs, GetFromAs, GetToAs, SetBy, SetFrom, SetTo).

For example, the following will animate the "radius" property for three seconds, from its current value, to the value 120 and will repeat this ten times.

C# Example

var radiusAnimation = CABasicAnimation.FromKeyPath ("radius");
radiusAnimation.Duration = 3;
radiusAnimation.To = NSNumber.FromDouble (120);
radiusAnimation.RepeatCount = 10;

The above works to set the “To” property to an NSObject, in this case the number 120.   If you want to set this for other kinds of objects, you can use the SetTo method, for example, the following sets the target color to a CGColor:

C# Example

var radiusAnimation = CABasicAnimation.FromKeyPath (“shadowColor");
radiusAnimation.Duration = 3;
radiusAnimation.SetTo (UIColor.Red.CGColor);
radiusAnimation.RepeatCount = 10;

Related content

Requirements

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

The members of CoreAnimation.CABasicAnimation are listed below.

See Also: CAPropertyAnimation

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
A constructor that initializes the object from the data stored in the unarchiver object.

Protected Constructors

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

ByNSObject. Value to increment by.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
FromNSObject. Initial value for the property to animate.
ToNSObject. Destination value for the property to animate.

Public Methods

static
FromKeyPath(String) : CABasicAnimation
Creates an animation from the given key path.
GetByAs<T>() : T
Returns the value to increment by, returned as an object of the specified type.
GetFromAs<T>() : T
Returns the initial value for the property to animate, returned as an object of the specified type.
GetToAs<T>() : T
Returns the destination value for the property to animate, returned as an object of the specified type.
SetBy(INativeObject)
Sets the value to increment by, by using a non-NSObject type.
SetFrom(INativeObject)
Sets the value for the initial value of the property to animate, by using a non-NSObject type.
SetTo(INativeObject)
Destination value for the property to animate (using INativeObject).