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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:09:55+00:00 2026-05-25T06:09:55+00:00

I’m trying to make a push animation from one side using a CATransition .

  • 0

I’m trying to make a push animation from one side using a CATransition. I do this in method which handles two UIViews, one for the background and another for the foreground. The animated UIView is be the foreground. However I don’t want the new content to replace the old one, so to do this I’m moving all the old content from the foreground to the background UIView expecting that it will just animate the push transition of the UIView from one side, but instead it replaces the old UIView. Is there any way to do what I’m attempting to do, something like locking the state of the UIViews from the moment where the foreground and background UIViews have the right content?

My code is something like this:

UIView *newView = argView; // argView is the view passed as a parameter to the method
// move views from foreground to background
for (UIView *v in [fgView subviews]) {
    [v removeFromSuperview];
    [bgView addSubview:v];
}

// Slide animation
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[fgView.layer addAnimation:transition forKey:nil];
[fgView addSubview:newView];

[edit] I’ve been doing some research. Apparently (or what I think might be happening) is that the background’s UIViews removal are adopting implicit animation. Is there a way to stop it from animating?

[edit] Answer: Yes, it can be done (disabling the implicit animation) and it is done with the following code

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions];
for (UIView *v in [fgView subviews]) {
    [v removeFromSuperview];
    [bgView addSubview:v];
}
[CATransaction commit];

This is what I did and it should work (according to apple’s developer portal) but it doesn’t, so the question is still open.

[edit] After a lot of testing and reading I have found out that the problem is that when I remove a view from its superview the Transition or Animation does not recognizes this change until later, so it responds outdated of the latest changes. Is there any way to force an update or to check when a removeFromSuperview or addSubview is finished?

[edit] What I need exactly is this:
1) the current state of the UIViews is: bgView with old views behind a shaded UIView or midView (this view shouldn’t be animated). A midView which is NEVER animated. A fgView with the current UIView.
2) I want to move the contents of fgView to bgView (which won’t be animated) and animate the appearance of a new UIView which is added to fgView (using Slide, Fade in/out or Flip animations).

  • 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-25T06:09:55+00:00Added an answer on May 25, 2026 at 6:09 am

    Maybe the better way is to make a “screenshot” of your old content and add the screenshot as a UIImageView, then you can change your UIView’s content to the new one.

    After this, you can easily add animations to the two views and there is no need to worry about the old content be changed.

    You can add the two files below into your project and get a UIView’s screenshot by invoke UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithUIView:view]];

    As it’s a UIImageView, so you don’t have to worry about the content of the view will be changed.

    UIImage+ImagewithUIView.h

    @interface UIImage (UIImage+ImagewithUIView)
    + (UIImage *)imageWithUIView:(UIView *)view;
    @end
    

    UIImage+ImagewithUIView.m

    @implementation UIImage (UIImage+ImagewithUIView)
    #pragma mark -
    #pragma mark TakeScreenShot
    static CGContextRef createBitmapContext(int pixelsWide, int pixelsHigh)
    {
        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
        CGBitmapInfo bitmapInfo = (kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst);
        CGContextRef bitmapContext = CGBitmapContextCreate(nil, pixelsWide, pixelsHigh, 8, 0, colorSpace, bitmapInfo);
        CGColorSpaceRelease(colorSpace);
    
        return bitmapContext;
    }
    
    + (UIImage *)imageWithUIView:(UIView *)view
    {
        CGSize screenShotSize = view.bounds.size;
        CGContextRef contextRef = createBitmapContext(screenShotSize.width, screenShotSize.height);
        CGContextTranslateCTM (contextRef, 0, screenShotSize.height);
        CGContextScaleCTM(contextRef, 1, -1);
    
        [view.layer renderInContext:contextRef];
        CGImageRef imageRef = CGBitmapContextCreateImage(contextRef);
        CGContextRelease(contextRef);
    
        UIImage *img = [UIImage imageWithCGImage:imageRef];
        CGImageRelease(imageRef);
        // return the image
        return img;
    }
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm making a simple page using Google Maps API 3. My first. One marker
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.