[SOLVED] Resetting of property values after completion of a CABasicAnimation
[SOLVED] Resetting of property values after completion of a CABasicAnimation
- Subject: [SOLVED] Resetting of property values after completion of a CABasicAnimation
- From: Vincent Coetzee <email@hidden>
- Date: Tue, 13 Nov 2007 13:54:17 +0200
Hi Bill,
Thanks very much for the suggestion, the removeOnCompletion property
did not make any difference, the flash still occurred, however your
second suggestion, using transactions worked like a charm. Problem
solved.
Thanks
Vincent
On 13 Nov 2007, at 1:27 PM, Bill Dudney wrote:
Hi Vincent,
I have a couple of ideas;
- set the removedOnCompletion property to NO on your basic animation
(i think the flash is happening because by default it is removed and
since you have not set the alpha to zero it bounces back to 1)
- use implicit animation instead of explicit and just tell the layer
to set its opacity to zero (which will animate automatically) and if
you need the duration to be one second you can specify that in a
transaction (check out http://developer.apple.com/documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Transactions.html)
- use a transition animation and remove the layer from its
superlayer, set the type to kCATransitionFade and the layer will
fade out before its removed
HTH,
-bd-
http://bill.dudney.net/roller/objc
On Nov 13, 2007, at 4:13 AM, Vincent Coetzee wrote:
Dear List,
I am using a CABasicAnimation to fade an item out. I am setting the
opacity to 1.0 in the fromValue and to 0.0 in the toValue.The
animation works perfectly and the item fades out, however once the
animation has completed, the property (in this case opacity) seems
to get reset to the original value of 1.0 so my item sudden pops
back before I get a chance to remove it completely. I have tried
everything I can think of to stop this irritating flash to no
avail. I list my code below. Any suggestions / criticisms would be
very welcome.
TIA
Vincent
- (void) fadeOut
{
CABasicAnimation *theAnimation;
ItemAnimationContext* context;
theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"];
theAnimation.duration=1.0;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.0];
context = [ItemAnimationContext onAnimation: theAnimation
endAction: @selector(fadeOutCompleted:) onItem: self];
[theAnimation setDelegate: context];
[[self layer] addAnimation:theAnimation forKey:@"animateOpacity"];
}
_______________________________________________
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
_______________________________________________
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