Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7844791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:00:18+00:00 2026-06-02T17:00:18+00:00

This is essentially the same question as posted here: Animating a custom property in

  • 0

This is essentially the same question as posted here: Animating a custom property in a CALayer
over a year ago and hasn’t been answered.

Im creating a custom layer and drawing a circle on it. I’d like to be able to animate the radius of the circle (and other properties later). From what i’ve read, i’ve set it up like so:

public class CircleLayer : CALayer
{

    //[Export("radius")]
     //public float Radius { get;set; }
    //EDIT: I've now changed the radius field to what is coded below


        public float Radius;

    [Export("radius")]
    public float getRadius()
    {
        return Radius;
    }

    [Export("setRadius:")]
    public void setRadius(float val)
    {
        Radius = val;
    }

    public float Thickness {get;set;}
    public CGColor Color {get;set;}
    public float GlowAmount {get;set;}

    private SizeF GlowOffset {get;set;}

    [Export ("needsDisplayForKey:")]
    static bool NeedsDisplayForKey (NSString key)
    {
        Console.WriteLine(key.ToString());

        if(key.Equals("radius"))
        {

            return true; 
        }
        else
            return false;

    }



    public CircleLayer ()
    {
        if(GlowAmount == 0.0f)
            GlowAmount = 10f;

        GlowOffset = new SizeF(0f,0f);
        //CALayer.NeedsDisplayForKey("radius");
    }



    public override void DrawInContext (CGContext context)
    {
        base.DrawInContext (context);
        Console.WriteLine("drawing...........");
        PointF centerPoint = new PointF(125,125);//this.Frame.Width/2,this.Frame.Height/2);


        //Outer circle
        context.AddEllipseInRect(new RectangleF(centerPoint.X - Radius,
                                                centerPoint.Y - Radius,
                                                Radius * 2,
                                                Radius * 2));
        //Inner circle
        context.AddEllipseInRect(new RectangleF(centerPoint.X - InnerRadius,
                                                centerPoint.Y - InnerRadius,
                                                InnerRadius * 2,
                                                InnerRadius * 2));

        //Fill in circle
        context.SetFillColor(Color);
        context.SetShadowWithColor(GlowOffset,GlowAmount,GlowColor);
        context.EOFillPath();


    }
}

But it just doesn’t work. I never get the radius key reported when NeedsDisplayForKey gets called (and prints them to the console). I can animate standard properties no problem (eg: scale)

Edit: Note that I can now successfully modify the value of the property Radius using SetValueForKey. If I do this I need to call SetNeedsDisplay() to update the screen, however i still cannot get the animation to work at all.

Edit #2: Sample attached: http://dl.dropbox.com/u/8617393/GraphicsTest1.zip

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:00:20+00:00Added an answer on June 2, 2026 at 5:00 pm

    This has unfortunately been impossible to do with MonoTouch – but we’ve fixed it for the next beta (5.3.3) which will hopefully be released soon.

    Once 5.3.3 has been released you can use this sample: https://github.com/xamarin/monotouch-samples/tree/monotouch-5.4/CustomPropertyAnimation to see how to do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is essentially the same as this one here . I'm using AnkhSVN
My question is essentially the same as this one: Polymorphic Association with multiple associations
I essentially have the same goal as in this question: Calling a jQuery plugin
I have looked at this question which is essentially the same but the OP
This questions involves 2 different implementations of essentially the same code. First, using delegate
This seems like a basic question, but I haven't found any clear answers. Essentially,
I have a use case with NServiceBus explained in this question. Essentially there is
This question comes from a range of other questions that all deal with essentially
So this is essentially a follow-up question on Finding duplicate records . We perform
So I have a DOM document that looks essentially like this <categories> <category id=1/>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.