Josh Kahane
Josh Kahane

Reputation: 17169

NSAnimationContext On Several Views Simultaneously

I have two NSViews. I have a simple need, to slide one view off screen and another into view.

I have been playing with NSAnimationContext and managed to achieve a good simple animation, however it won't animate both my views.

Here is my code:

[NSAnimationContext beginGrouping];
    
    [[NSAnimationContext currentContext] setDuration:1.4];
    [[NSAnimationContext currentContext] setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
    [[NSAnimationContext currentContext] setCompletionHandler:^{
        //...Completion Callback Code goes here...
        
    }];
    
    [self.loginView.animator setFrameOrigin:NSMakePoint(self.loginView.frame.origin.x + animViewOffset, self.loginView.frame.origin.y)];
    [self.signUpView.animator setFrameOrigin:NSMakePoint(self.signUpView.frame.origin.x + animViewOffset, self.signUpView.frame.origin.y)];
    
    [NSAnimationContext endGrouping];

All I am doing to moving both views from left to right, 1000 pixels (that's animViewOffset).

As the code is currently, it will only animate singUpView. If I comment out the line setting the signUpView frame origin, it will animate the loginView. But it will never animate them both together.

How can I make it so that they animate together?

Upvotes: 1

Views: 304

Answers (0)

Related Questions