I am trying to get the animation to work with a custom property in CALayer.
But I just can’t figure out how to do it right. The key "myCounter" is never sent to NeedsDisplayForKey. Are there some steps I'm missing? Below is the class I'm testing, which I am adding to the layer elsewhere. Has anyone gotten a custom property for animation using monotote?
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;
}
}
source
share