Hi all,

I'm trying to use CATransition in my app to provide an animated slide 
transition when swapping views. I don't want to permanently layer back my views 
because they cause various glitches (no subpixel antialiasing, resize issues 
when backed with a CATiledLayer, etc.) To get around this, I want to 
temporarily layer back my view, run the animation, and then disable layer 
backing after the animation completes. This is my code thus far:

CATransition *transition = [CATransition animation];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
transition.timingFunction = [CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[parentView setWantsLayer:YES];
[CATransaction begin];
[CATransaction setCompletionBlock:^(void) {
        [parentView setWantsLayer:NO];
}];
[parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
forKey:@"subviews"]];
[[parentView animator] replaceSubview:firstView with:secondView];
[CATransaction commit];

With this code, the animation doesn't run (the views just get swapped without 
animation but the completion block is still called). The problem seems to be 
the fact that I'm calling -setWantsLayer: immediately before the animation 
begins. If I call this method in -awakeForNib, the animation will run. I'm 
thinking that this might be some sort of runloop issue, but I have no idea what 
I can do to work around this. I've tried moving my -setWantsLayer: call to 
various places within the animation method but this has no effect.

Any help is greatly appreciated.
Thanks,
Indragie
--------
http://indragie.com _______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to