I have a CALayer
subclass with float animAngle
as property marked as @dynamic
. I have implemented methods actionForKey
, initWithLayer
, needsDisplayForKey
and drawInContext
for subclass.
The definition for actionForKey
is as follows
- (id<CAAction>)actionForKey:(NString *)event {
if([event isEqualToString:@"animAngle"]) {
return [self animationForKey:event];
}
return [super actionForKey:event];
}
And
- (CABasicAnimation *)animationForKey:(NSString *)key
{
NSString *animValue = [[self presentationLayer] valueForKey:key];// Logs as 0
CABasicAnimation *anim;
if([key isEqualToString:@"animAngle"]) {
anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
anim.repeatCount = HUGE_VAL;
anim.autoreverses = YES;
//anim.fromValue = [[self presentationLayer] valueForKey:key]; // setting animation value from layer property as in here does not work.
anim.fromValue = [NSNumber numberWithFloat:0.5f]; // This works
}
anim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
anim.duration = 0.11;
return anim;
}
In Someother class:
myCASublayer.animAngle = 0.5f;
Somehow the CABasicAnimation
being returned is not able to properly use the layer "animAngle
" property.
What would i be possibly doing wrong here?
animAngle
the other iswiggleAngle
– Disk