• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core animation update layer properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core animation update layer properties


  • Subject: Re: Core animation update layer properties
  • From: David Duncan <email@hidden>
  • Date: Mon, 10 Dec 2007 13:21:46 -0800

On Dec 9, 2007, at 6:57 AM, Nik Youdale wrote:

Hey there,

I want to fade out a layer (from opacity 1 to 0) using a CABasicAnimation.

I have tried the following:

CABasicAnimation *a = [CABasicAnimation animationWithKeyPath:@"opacity"];
a.fromValue = [NSNumber numberWithFloat:1.0];
a.toValue = [NSNumber numberWithFloat:0.0];
a.duration = 1.0;
[layer addAnimation:a forKey:@"myFadeOut"];


This works fine, however when the animation completes the layers opacity reverts back to its value before the animation began (1.0 in this case).

Is there any way I can tell the animation to update the real opacity property, instead of just the 'presentation' one?

If you want the animation to stick after the fact, then you need to do two things.
1) Set the fillMode property to kCAFillModeForwards (this sets the animation to "stick" after its duration)
2) Set the removedOnCompletion property to NO (or the animation will be removed when its duration completes and it will rebound anyway).


You will likely also want to set a delegate on the animation so that you know when it completes to do whatever additional actions are necessary afterwards (such as removing the layer from the layer tree).
--
David Duncan
Apple DTS Animation and Printing
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


References: 
 >Core animation update layer properties (From: Nik Youdale <email@hidden>)

  • Prev by Date: How can I create a multipage PDF?
  • Next by Date: Re: How can I create a multipage PDF?
  • Previous by thread: Re: Core animation update layer properties
  • Next by thread: Extra call to validateMenuItem before triggering action; new in Leopard?
  • Index(es):
    • Date
    • Thread