Why are my CATransitions acting up?

Posted by Regan on Stack Overflow See other posts from Stack Overflow or by Regan
Published on 2010-12-23T20:50:47Z Indexed on 2010/12/23 20:54 UTC
Read the original article Hit count: 351

Filed under:
|

I am using the following code to switch between views with CATransition.

CATransition *applicationLoadViewIn = [CATransition animation];

    [applicationLoadViewIn setDuration:20];

    [applicationLoadViewIn setType:kCATransitionPush];

    [applicationLoadViewIn setSubtype:kCATransitionFromTop];

    [applicationLoadViewIn setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];

    ViewToSwitchTo *myviewcontroller = [[ViewToSwitchTo alloc] init];

    [self.view.layer addAnimation:applicationLoadViewIn forKey:kCATransitionPush];

    [self.view addSubview:myviewcontroller.view];

It functions mostly how I want it to. It pushes from the top like it should, however it for some reason acts strangely. First, the view I am switching to starts coming in from the bottom like it should, but for some reason, the view that I am switching FROM appears over the top of it with low opacity, so you see both of them. However, you also see the view that is coming in, shifted maybe 100 pixels upwards, on top of itself and the other view, once again with low opacity. Just before the halfway point of the the transition, everything works fine, you only see the view that is coming in and the view going out, doing what they should be doing. But slightly after the halfway point, the view I am switching to appears in its final destination, under the view I am switching from, and the view I am switching from has been reduced in opacity.

What is going on here?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about catransition