I'm trying to get animation working on a custom property in a CALayer.
But I just just am not able to figure out how to get this working correctly. The key "myCounter" is never sent to NeedsDisplayForKey. Are there some steps I'm missing? Below is the class I'm testing which I add to a layer elsewhere. Has anyone got a custom property to animate using monotouch?
public class TestProperty : CALayer
{
//this line updated based on feedback below**********
public uint myCounter { [Export ("myCounter")] get; [Export setMyCounter:")] set; }
public TestProperty ()
{
CABasicAnimation anim = CABasicAnimation.FromKeyPath("myCounter");
anim.From = NSNumber.FromInt32(1);
anim.To = NSNumber.FromInt32(10);
anim.Duration = 1.0f;
anim.RepeatCount = float.MaxValue;
anim.AutoReverses = true;
this.AddAnimation(anim,null);
}
[Export ("needsDisplayForKey:")]
static bool NeedsDisplayForKey (NSString key)
{
Console.WriteLine("{0}", key.ToString());
if(key.Equals("myCounter"))
{
return true; //never gets here
}
else
return false;
}
}