Re: Flip and Enlarge CALayer at the same time
Re: Flip and Enlarge CALayer at the same time
- Subject: Re: Flip and Enlarge CALayer at the same time
- From: Gustavo Pizano <email@hidden>
- Date: Tue, 22 Jun 2010 22:50:17 +0200
Hello everybody once again.
So I want to update my advances.
IT'S WORKING NOW! lets say about 80% of it.
this is what Im doing:
- (void)enlargeCALayer{
CABasicAnimation * frameAnim = [CABasicAnimation animationWithKeyPath:@"position"];
[frameAnim setFromValue:[NSValue valueWithPoint:self.position]];
NSRect r = [self superlayer].bounds;
NSPoint p = NSMakePoint((r.origin.x + r.size.width)/2.0f, (r.origin.y + r.size.height)/2.0f);
[frameAnim setToValue:[NSValue valueWithPoint:p]];
frameAnim.cumulative= NO;
frameAnim.removedOnCompletion=NO;
frameAnim.autoreverses = NO;
frameAnim.fillMode=kCAFillModeForwards;
frameAnim.delegate = superView;
// Prepare the animation from the old size to the new size
CGRect oldBounds = self.bounds;
CGRect newBounds = oldBounds;
newBounds.size = CGSizeMake(300.0f, 300.0f);
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"bounds"];
animation.fromValue = [NSValue valueWithRect:NSRectFromCGRect(oldBounds)];
animation.toValue = [NSValue valueWithRect:NSRectFromCGRect(newBounds)];
// Update the layer's bounds so the layer doesn't snap back when the animation completes.
self.bounds = newBounds;
// Add the animation, overriding the implicit animation.
CAAnimationGroup * g = [CAAnimationGroup animation];
[g setAnimations:[NSArray arrayWithObjects:frameAnim,animation,nil]];
g.delegate = superView;
g.removedOnCompletion=NO;
g.autoreverses = NO;
g.duration = 0.15;
g.fillMode=kCAFillModeForwards;
[self addAnimation:g forKey:@"flipper"];
}
so with this method and the in the previous post (setFaceUp), I see the layer appearing and then rotating while changing dimensions and position,
for the other 20% remaining I have these unsolved things.
The content of the front layer, then one that appears after half the rotations (or at least thats what the eye does). should I place an image as the content of the layer and once the whole animation ends remove the layer and add the the view with the contents?, Actually this is what Im doing in the animation's delegate, but while the animation ends I see is the black background color of the front Layer while rotating and changing dimensions, so any suggestions :S, tricks or tips?
Thanks a lot.
Gustavo
_______________________________________________
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