Add animation layer and then remove animation layer
Add animation layer and then remove animation layer
- Subject: Add animation layer and then remove animation layer
- From: Steven Riggs <email@hidden>
- Date: Fri, 10 Oct 2008 20:53:30 -0400
I'm enabling a core animation when I replace a subview and I want the
animation layer to go away when the transition is finished so I don't
have the blinky window resizing and other fun fade effects that I
don't want.
I have a problem with my code. The first time I changeRightView the
CALayer appears and the view is transitioned from the right and the
CALayer is gone. That's just what I wanted. The next time I
changeRightView the CALayer appears but the view transitions using the
default fade and then the CALayer stays. I assume
animationDidStop:finished: never gets called because the CATransition
never gets created or applied. So every other transition fails like
this. good, bad, good, bad, good, bad... what did I miss?
See code below. Thanks for the help!
-Steve
- (void) changeRightView
{
//enable CA layer
[rightPlaceHolderView setWantsLayer:YES];
//transition comes from the right
CATransition *transition = [CATransition animation];
[transition setType:kCATransitionPush];
[transition setSubtype:kCATransitionFromRight];
//set delegate for CAAnimation
[transition setDelegate:self];
[rightPlaceHolderView setAnimations:[NSDictionary
dictionaryWithObject:transition
forKey:@"subviews"]];
//replace the view
[[rightPlaceHolderView animator] replaceSubview:currentRightView
with:eventListView];
currentRightView = eventListView;
//size the view
newBounds.origin.x = 0;
newBounds.origin.y = 0;
newBounds.size.width = [[currentRightView superview] frame].size.width;
newBounds.size.height = [[currentRightView superview]
frame].size.height;
[currentRightView setFrame:[[currentRightView superview] frame]];
// make sure our added subview is placed and resizes correctly
[currentRightView setFrameOrigin:NSMakePoint(0,0)];
[currentRightView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
}
- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
//get rid of the animation layer so there's no fading on window resize
[rightPlaceHolderView setWantsLayer:NO];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden