我有一个CPTPlotSpaceAnnotation
,其contentLayer
属性是CPTBorderedLayer
个对象。我尝试使用以下内容为CPTBorderedLayer
对象设置动画:
CGRect originalBounds = annotation.contentLayer.bounds;
CGRect expandedBounds = annotation.contentLayer.bounds;
expandedBounds.size.width *= 1.5f;
expandedBounds.size.height *= 1.5f;
CABasicAnimation* boundsAnimation = [CABasicAnimation animationWithKeyPath:@"bounds"];
boundsAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
boundsAnimation.fromValue = [NSValue valueWithCGRect:originalBounds];
boundsAnimation.toValue = [NSValue valueWithCGRect:expandedBounds];
boundsAnimation.duration = 1.0f;
boundsAnimation.removedOnCompletion = NO;
[annotation.contentLayer addAnimation:boundsAnimation forKey:@"bounds"];
但这不是动画。将bounds
直接设置为expandedBounds
有效,但它不会生成动画。想法?
答案 0 :(得分:0)
问题是我的collapsesLayers
属性设置为CPTGraphHostingView
YES
。将其设置为NO
可解决问题。