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

  • Home
  • SEARCH
  • 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 7783925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:59:09+00:00 2026-06-01T19:59:09+00:00

I created 2 NSAnimation objects of flipping the view with another view. I’d like

  • 0

I created 2 NSAnimation objects of flipping the view with another view. I’d like to run 2 these animations simultaneously. I cannot use NSViewAnimation, since it’s now about animating any of view properties.

Here is the animation creation:

self.animation = [[[TransitionAnimation alloc] initWithDuration:1.0 animationCurve:NSAnimationEaseInOut] autorelease];
[self.animation setDelegate:delegate];
[self.animation setCurrentProgress:0.0];

[self.animation startAnimation];

I tried to link 2 animations, but probably it didn’t work for some reason. I took an example from:
Apple developer site

configuring the NSAnimation object to use NSAnimationNonblocking doesn’t show any animation at all…

EDIT: The second animation is exactly the same as the first one and created in the same place the first is created.

TransitionAnimation is a subclass of NSAnimation, where the setCurrentProgress looks like that:

- (void)setCurrentProgress:(NSAnimationProgress)progress {
    [super setCurrentProgress:progress];
    [(NSView *)[self delegate] display];    
}

the delegate is NSView in this case, which in its drawRect function applies a time-dependent CIFilter on a CIImage. The problem is that it runs synchronous and the second animation starts right after end of the first. Is there a way to run them simultaneously?

  • 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-01T19:59:11+00:00Added an answer on June 1, 2026 at 7:59 pm

    NSAnimation is not really the best choice for animating multiple objects and their properties simultaneously.

    Instead, you should make your views conform to the NSAnimatablePropertyContainer protocol.

    You can then set up multiple custom properties as animatable (in addition to the properties already supported by NSView), and then you can simply use your views’ animator proxy to animate the properties:

    yourObject.animator.propertyName = finalPropertyValue;
    

    Apart from making animation very simple, it also allows you to animate multiple objects simultaneously using an NSAnimationContext:

    [NSAnimationContext beginGrouping];
    firstObject.animator.propertyName = finalPropertyValue1;
    secondObject.animator.propertyName = finalPropertyValue2;
    [NSAnimationContext endGrouping];
    

    You can also set the duration and supply a completion handler block:

    [NSAnimationContext beginGrouping];
    [[NSAnimationContext currentContext] setDuration:0.5];
    [[NSAnimationContext currentContext] setCompletionHandler:^{
        NSLog(@"animation finished");
    }];
    firstObject.animator.propertyName = finalPropertyValue1;
    secondObject.animator.propertyName = finalPropertyValue2;
    [NSAnimationContext endGrouping];
    

    The NSAnimation and NSViewAnimation classes are much older than the animator proxy support and I highly recommend that you move away from them if possible. Supporting the NSAnimatablePropertyContainer protocol is much simpler than managing all the NSAnimation delegate stuff. The Lion support for custom timing functions and completion handlers means there’s really no need to do that any more.

    For a standard NSView object, if you want to add animation support to a property in your view, you just need to override the +defaultAnimationForKey: method in your view and return an animation for the property:

    //declare the default animations for any keys we want to animate
    + (id)defaultAnimationForKey:(NSString *)key
    {
        //in this case, we want to add animation for our x and y keys
        if ([key isEqualToString:@"x"] || [key isEqualToString:@"y"]) {
            return [CABasicAnimation animation];
        } else {
            // Defer to super's implementation for any keys we don't specifically handle.
            return [super defaultAnimationForKey:key];
        }
    }
    

    I’ve created a simple sample project that shows how to animate multiple properties of a view simultaneously using the NSAnimatablePropertyContainer protocol.

    All your view needs to do to update successfully is make sure that setNeedsDisplay:YES is called when any of the animatable properties are modified. You can then get the values of those properties in your drawRect: method and update the animation based on those values.

    If you want a simple progress value that is analogous to the way things work with NSAnimation, you could define a progress property on your view and then do something like this:

    yourView.progress = 0;
    [yourView.animator setProgress:1.0];
    

    You can then access self.progress in your drawRect: method to find out the current value of the animation.

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

Sidebar

Related Questions

I created a batch file to run SqlMetal and generate Linq2Sql data classes, check
I created an anchor like this: <a id=create /> and it works in IE
Created application is working toooo slow, looks like there are a lot of memory
Created an Accordion side bar using jQuery 1.2.6. I cannot access newer version of
created a singleview application with storyboard. Added three viewcontrollers apart from the one view
Created a custom validation attribute and I would like to get it to work
I am trying to use a context menu I created for a Dialog Box,
I created a project without ARC . I want to use a third party
I created a Role entity, I would like to do CRUD operations on it.
Created a group of related providers using the provider pattern. Now would like to

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.