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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:31:35+00:00 2026-05-18T06:31:35+00:00

I have two UIImageViews on my object, and I’m trying to animate them to

  • 0

I have two UIImageViews on my object, and I’m trying to animate them to page like a book. I used some of the built in animations for a while (UIViewAnimationTransitionFlipFromLeft/Right), and decided I could do better. I found a nice example for half of the animation I wanted here: http://fiftysixtysoftware.com/blog/2009/uiview-pageopen-sample-project/

I was able to extrapolate from there to get my animation working… but the problem I’m having is that my animating image (the right image) always shows up beneath the left image.

Here’s code in the init:

// set up some rects for use later
landscapeLeftRect = CGRectMake(0, 12, 512, 725);
landscapeRightRect = CGRectMake(512, 12, 512, 725);

// all our images
imageLeft = [[UIImageView alloc] initWithFrame:portraitRect];
imageRight = [[UIImageView alloc] initWithFrame:landscapeRightRect];

…and performing the actual animation (note that this is the second half of the animation, the half that “overlaps” with my imageLeft view):

// set the image to be nextLeft
//[imageRight setImage:image.nextLeft];
[self.view sendSubviewToBack:imageLeft];
[self.view bringSubviewToFront:imageRight];
//[imageRight.layer setZPosition:1.0f];
[imageRight setFrame:landscapeLeftRect];

// remove any previous animations
[imageRight.layer removeAllAnimations];

// set up the anchorPoint and center
if (imageRight.layer.anchorPoint.x != 1.0f) {
    imageRight.layer.anchorPoint = CGPointMake(1.0f, 0.5f);
    imageRight.center = CGPointMake(imageRight.center.x + imageRight.bounds.size.width/2.0f, imageRight.center.y);
}

// create an animation to hold the first half of the page turning forward
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = YES;
transformAnimation.duration = 0.40f;
transformAnimation.delegate = self;
transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// start the animation from the current state
CATransform3D endTransform = CATransform3DMakeRotation(3.141f/2.0f,
                                                       0.0f,
                                                       -1.0f,
                                                       0.0f);
// these values control the 3D projection outlook
endTransform.m34 = -0.001f;
endTransform.m14 = 0.0015f;
transformAnimation.fromValue = [NSValue valueWithCATransform3D:endTransform];
// we should end up at the beginning...
transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];

[imageRight.layer addAnimation:transformAnimation forKey:nil];

Things I’ve tried: (you can see both in the code above)

  • bringSubviewToFront/sendSubviewToBack
  • setting a Z index on the layer

Thanks in advance for any advice or wisdom. Again, the problem is with my imageLeft always displaying on top of the animation.

  • 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-18T06:31:35+00:00Added an answer on May 18, 2026 at 6:31 am

    I faced the same problem and just found that you can fix it by setting the zPosition of the view.
    I used something like this:

    viewThatShouldBeSentToTheBack.layer.zPosition=-10000;

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

Sidebar

Related Questions

I have two UIImageViews, one of them is moving from left to right, the
I have two UIImageViews that contain images with some transparent area. Is there any
I'm trying to have multiple UIImageView 's each with two buttons - A Take
I have two UIImageView 's, and I want to concatenate them both to be
How can I draw a straight line between two UIImageViews and have the line
I have this UIView that contains two identical UIImageViews juxtaposed. I am looking to
I have placed 3 images into UIImageViews using xcode4 interface builder: background, and two
I have two views that I would like to fade in and out. I
I have an odd question here. I have two animations set up for a
I have created two view controllers in which there is UIImage animations.Its crashing frequently

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.