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 8922879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:57:36+00:00 2026-06-15T06:57:36+00:00

NSAnimation won’t let me animate NSColor changes. How do I do this?

  • 0

NSAnimation won’t let me animate NSColor changes. How do I do this?

  • 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-15T06:57:37+00:00Added an answer on June 15, 2026 at 6:57 am

    You can use blendedColorWithFraction:ofColor:. In your animation method (whichever method is handling the animation’s current value [if you don’t have one, simply make one]):

    NSColor *startColor = [NSColor redColor];
    NSColor *targetColor = [NSColor blueColor];
    
    float progress = [animation currentValue];
    NSColor *currentColor = [startColor blendedColorWithFraction:progress ofColor:targetColor];
    

    Edit:

    What you can do is create a subclass of NSAnimation. Your subclass just needs to override the setCurrentProgress: method to determine how far along the animation you are. You can configure the rest of the animation exactly the same way. The protocol may be overkill in this scenario but it gives your subclassed animation a dedicated way to give the NSColor back to the class instance that created the animation.

    @protocol MyAnimationTarget
    - (void) setColorOfSomething:(NSColor *);
    @end
    
    @interface MyAnimation : NSAnimation
    @property id<MyAnimationTarget> target;
    @property NSColor *color1;
    @property NSColor *color2;
    @end
    
    @implementation MyAnimation
    @synthesize target = _target;
    @synthesize color1 = _color1;
    @synthesize color2 = _color2;
    
    - (void) setCurrentProgress:(NSAnimationProgress) d
    {
        [super setCurrentProgress:d];
        NSColor *currentColor = [self.color1 blendedColorWithFraction:d ofColor:self.color2];
        [self.target setColorOfSomething:currentColor];
    }
    
    @end
    

    In your other code:

    MyAnimation *myAnim = [[MyAnimation alloc] init];
    myAnim.target = self; // assuming self has a setColorOfSomething: method
    myAnim.color1 = [NSColor redColor];
    myAnim.color2 = [NSColor blueColor];
    // set up other animation stuff
    [myAnim startAnimation];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the right way to continuously animate the frameRotation of
I created 2 NSAnimation objects of flipping the view with another view. I'd like
I am creating a system tray program with a shortcut/context menu, but I can't
I'm trying to call a method of the below (Scroll animation class) type from
I am making a simple app in which filled circles bounce around the screen.
I am trying to use a context menu I created for a Dialog Box,
I want to make a view move to a different position on window resize.
I have javascript function that show alert message and after 2 sec hide it.
I want to create an application in which i want to record user voice.I
I'm adding a button in the middle of my initWithNibName:bundle: , when i add

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.