• 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
Why does a custom CALayer property work differently from a standard one?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why does a custom CALayer property work differently from a standard one?


  • Subject: Why does a custom CALayer property work differently from a standard one?
  • From: Roland King <email@hidden>
  • Date: Thu, 25 Oct 2012 19:38:17 +0800

Ive been struggling with this for a couple of days now.

I have a custom CALayer with a custom property, percentage. It's @dynamic and set up to cause a redraw.

+(BOOL)needsDisplayForKey:(NSString *)key
{
	return [ @"percentage" isEqualToString:key ];
}

I return CABasicAnimations for percentage and for position with the code at the bottom in actionForKey:. The position one just makes the position change really slowly.

For position all I have to do is make a CABasicAnimation, set the duration and nothing else and return it, the position animates smoothly from where it was to where it's going.

If I do the same for 'percentage', just return a CABasicAnimation with the duration set, it doesn't animate, it just goes instantly to the final value. For this one I have to explicitly set the 'fromValue' to the current value in the presentation layer, leaving it nil just doesn't do the job. It finds the 'toValue' itself, but I have to tell it where it's coming from.

Why do they work differently? This prevents me from using addAnimation:forKey: for 'percentage' because each one is different, depending what the current value of percentage is.


-(id<CAAction>)actionForKey:(NSString *)event
{

	if( [ event isEqualToString:@"position" ] )
	{
		CABasicAnimation *animation = [ CABasicAnimation animationWithKeyPath:@"position" ];
		animation.duration = 7.f;
		return animation;
	}

	if( [ event isEqualToString:@"percentage" ] )
	{
		CABasicAnimation *animation = [ CABasicAnimation animationWithKeyPath:@"percentage" ];
		animation.duration = 2.f;
		animation.fromValue = [ self.presentationLayer valueForKey:event ];
		return animation;
	}

	return [ super actionForKey:event ];;
}
_______________________________________________

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

  • Follow-Ups:
    • Re: Why does a custom CALayer property work differently from a standard one?
      • From: Corbin Dunn <email@hidden>
  • Prev by Date: Binding InfoPanel to currentDocument
  • Next by Date: RE: [Q] a view is associated with more than one view controller?
  • Previous by thread: Re: Binding InfoPanel to currentDocument
  • Next by thread: Re: Why does a custom CALayer property work differently from a standard one?
  • Index(es):
    • Date
    • Thread