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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T07:19:15+00:00 2026-06-06T07:19:15+00:00

I am trying to animate sliding out one view from a window and simultaneous

  • 0

I am trying to animate sliding out one view from a window and simultaneous sliding in another. Like so:

     Window
------------------  
|----------------| ------------------
||              || |                |
||     view     || |      view      |
||  sliding out || |   sliding in   |
|----------------| ------------------
------------------  
      <---                <---

I’m using layer backed views, trying to use implicit animation and a CATransaction. What’s happening is that the view sliding out animates, but the one sliding in, just jumps into place. Here’s my code:

    NSView *slidingInView = nil;
    NSView *slidingOutView = nil;
    if (currentState.primaryView != nextState.primaryView) {
        // Slide in a primary view
        [self.window.contentView addSubview:nextState.primaryView];
        CGRect frame = nextState.primaryView.layer.frame; 
        frame.origin.x = slideFromRight ? frame.size.width : 0 - frame.size.width;
        [nextState.primaryView.layer setPosition: frame.origin];

        slidingInView = nextState.primaryView;
        slidingOutView = currentState.primaryView;
    }

    [CATransaction begin];
    [CATransaction setValue:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]
                     forKey:kCATransactionAnimationTimingFunction];
    [CATransaction setAnimationDuration:1.0f];
    [CATransaction setCompletionBlock:^{
        [slidingOutView removeFromSuperview];
    }];

    // Slide in the new view
    slidingInView.layer.position = CGPointMake(0.0f, 0.0f);

    // if there is a view in place already, slide it out to the left.
    if (slidingOutView != nil) {

        CGRect frame = slidingOutView.layer.frame;
        frame.origin = CGPointMake(slidingOutView.layer.frame.size.width, slidingOutView.layer.frame.origin.y);
        if (slideRight)
            frame.origin = CGPointMake(0-slidingOutView.layer.frame.size.width, slidingOutView.layer.frame.origin.y);

        [slidingOutView.layer setPosition: frame.origin];
    }

    [CATransaction commit];

This is a complete mystery to me. Does anyone have a clue? My window’s contentView has setWantsLayer: YES, as has all the views I’m sliding in.

  • 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-06T07:19:18+00:00Added an answer on June 6, 2026 at 7:19 am

    Implicit animations only work for standalone layers (layer that are not backing up a view).

    You need to explicitly animate the layer (and change the property value since it doesn’t happen by default). It would look something like

    CABasicAnimation *slideIn = [CABasicAnimation animationWithKeyPath:@"position"];
    [slideIn setToValue:[NSValue valueWithCGPoint:myNewEndPoint]];
    [slideIn setFromValue:[NSValue valueWithCGPoint:[[slidingInView layer] position]]];
    [[slidingInView layer] addAnimation:slideIn forKey:@"mySlideInAnimation"];
    [[slidingInView layer] setPosition:myNewEndPoint];
    

    Also: unless you have changed the anchor point, the position of the layer should be in the center (which means that setting it to (0,0) will make 3/4 of the layer appear off-screen

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

Sidebar

Related Questions

I'm trying to animate a dot from one point to another on a map.
I'm trying to animate some text 'zooming out' on top of another view. My
I'm trying to make a sliding panel using .animate function because I want it
I'm trying to animate a view sliding into view and bouncing once it hits
I'm trying to animate a layer at exact moments during a view's cycle. Let's
I'm trying to figure out how to animate the change from Visibile to Hidden
I'm trying to animate a UIWebview being removed from the screen. I'm using an
I am trying to animate an NSPanel derived window with a fade-in while sliding
I'm trying to animate the height of a dataview, but it's currently just sliding
I'm trying to animate an image using KineticJS to move across the screen, but

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.