I want to animate a subclass of CALayer. This layer drawes a "donut"-chart piece. I set an start- & endAngle to the layer.
I tried with CABasicAnimation
My Layer
+ (BOOL)needsDisplayForKey:(NSString *)key {
return [key isEqualToString:@"endAngle"] ? YES : [super needsDisplayForKey:key];
}
- (void)drawInContext:(CGContextRef)ctx {
    CGFloat lineWidth = self.circleRingWidth / 2;
    CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
    CGFloat radius = (MIN(center.x-1, center.y-1) + lineWidth/2);
    CGContextBeginPath(ctx);
    CGContextSetAllowsAntialiasing(ctx, YES);
    CGContextAddArc(ctx, center.x, center.y, radius - kDefaultRingWidth, self.startAngle,      
                                                             self.endAngle, NO);
    CGContextSetBlendMode(ctx, kCGBlendModeColor);
    CGContextSetLineWidth(ctx, lineWidth);
    CGContextSetStrokeColorWithColor(ctx, self.color ? self.color.CGColor : [UIColor 
                                                             clearColor].CGColor);
    CGContextDrawPath(ctx, kCGPathStroke);
}
When i call setSelectedIndex
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"circleRingWidth"];
animation.duration = 2.0f;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
animation.fromValue = [NSNumber numberWithFloat:DEFAULT_RING_WIDTH];
animation.toValue = [NSNumber numberWithFloat:SELECTED_RING_WIDTH];
[self.selectedLayer addAnimation:animation forKey:@"circleRingWidth"];
self.selectedLayer.circleRingWidth = SELECTED_RING_WIDTH;