Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Explicit Animation Woes




On Mar 15, 2008, at 6:37 AM, Dan Saul wrote:

It does! Excellent. Any idea why this one works when the other one
doesn't (or is it just trial and error really)?

Dan,

The 'frame' property of a layer is somewhat different than the AppKit notion of a frame — frame for a layer is a calculated property, derived from the 'bounds', 'position', 'anchor point', and 'transform' of a layer. Explicit animations on the frame property are not supported, but the primitive properties that make up the frame (like 'position') are. (Please file a bug at <http://bugreporter.apple.com> if you think this should be supported.)

However, it sounds like you can still use implicit animations for your situation. Just adjust the timing function and repeat count of the animation you return from the layer's delegate's - actionForLayer:forKey: method: when animating the 'frame' property. The delegate method will get called for the primitive properties of 'frame' that you change by setting the frame:

// somewhere in your code
layer.frame = CGRectMake(...);


// in the layer's delegate - (id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)key {

// 'position' is modified when changing the origin of the 'frame' property

if ([key isEqualToString:@"position"]) {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:key];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.repeatCount = 100.0;
return animation;
}


    return nil; // do the default animation for everything else
}

I didn't compile that, but it should give you the idea of how to go about it. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden


This email sent to email@hidden
References: 
 >Explicit Animation Woes (From: "Dan Saul" <email@hidden>)
 >Re: Explicit Animation Woes (From: Patrick Geiller <email@hidden>)
 >Re: Explicit Animation Woes (From: "Dan Saul" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.