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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:31:09+00:00 2026-05-30T18:31:09+00:00

For some reason, a CATransition won’t animate if the animation is added to the

  • 0

For some reason, a CATransition won’t animate if the animation is added to the subview’s layer directly after the subview is added:

transitionView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[transitionView setBackgroundColor:[UIColor redColor]];
[[self contentView] addSubview:transitionView];

CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:@"cube"];
[animation setDuration:1.0];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[animation setSubtype:@"fromRight"];

[[transitionView layer] addAnimation:animation forKey:nil];

But if the animation is added after a slight delay:

transitionView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[transitionView setBackgroundColor:[UIColor redColor]];
[[self contentView] addSubview:transitionView];

CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:@"cube"];
[animation setDuration:1.0];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[animation setSubtype:@"fromRight"];

[self performSelector:@selector(animate) withObject:nil afterDelay:0.00001];

–

- (void)animate
{
    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];
    [animation setType:@"cube"];
    [animation setDuration:1.0];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
    [animation setSubtype:@"fromRight"];

    [[transitionView layer] addAnimation:animation forKey:nil];
}

The transition will work as expected. Is there any reason for 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-05-30T18:31:10+00:00Added an answer on May 30, 2026 at 6:31 pm

    I’ve seen this behavior too. I think it’s because the layer is in the “model” layer hierarchy that you can access, but it hasn’t yet been added to the “real” data structures that represent what’s actually on the screen.

    Anyway, you can work around it by using [CATransaction flush] like this:

    transitionView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [transitionView setBackgroundColor:[UIColor redColor]];
    [[self contentView] addSubview:transitionView];
    
    // Synchronize the implementation details with my changes so far.
    [CATransaction flush];
    
    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];
    [animation setType:@"cube"];
    [animation setDuration:1.0];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
    [animation setSubtype:@"fromRight"];
    
    [[transitionView layer] addAnimation:animation forKey:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason there's a variable called d that is defined immediately after I
For some reason my javascript won't execute when my submit button is pressed. It's
For some reason my divs won't center horizontally in a containing div: .row {
For some reason jquery's .hide() won't hide a div that contains a file input
For some reason after I installed Boot Camp, my os x terminal started to
For some reason, my script isn't writing out the text after I remove the
For some reason @store object with three attributes won't assign the third value(generated token
For some reason, after going through Phonegap's non-inclusive instructions (it doesn't even mention setting
For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
for some reason when I try to call CocoaAsyncSocket's onSocket:didReadData:withTag method, it's failing and

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.