0

我正在尝试在 MKMapView 的注释下方添加动画,但没有运气。我尝试更改 CAShapeLayer zPosition,但圆圈最终位于地图下方。这是我当前将动画添加到地图的代码:

int radius = 55;
CAShapeLayer *circle = [CAShapeLayer layer];

circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius)
                                         cornerRadius:radius].CGPath;

circle.position = CGPointMake(CGRectGetMidX(self.view.frame)-radius,
                              CGRectGetMidY(self.view.frame)-radius);

circle.fillColor = [UIColor clearColor].CGColor;
circle.strokeColor = [UIColor blackColor].CGColor;
circle.lineWidth = radius*2;
circle.opacity = 0.5;

[self.mapView.layer addSublayer:circle];

CABasicAnimation *drawAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
drawAnimation.duration            = 2.5; // "animate over 10 seconds or so.."
drawAnimation.repeatCount         = 100.0;  // Animate only once..
drawAnimation.removedOnCompletion = YES;   // Remain stroked after the animation..

drawAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
drawAnimation.toValue   = [NSNumber numberWithFloat:1.0f];

functionWithName:kCAMediaTimingFunctionEaseIn];

[circle addAnimation:drawAnimation forKey:@"drawCircleAnimation"];
4

1 回答 1

0

在 3 天没有答案后,我决定从 mkview 中删除我的注释,并将动画和与注释对应的图像放在地图上方的另一个视图中。

于 2012-12-07T18:46:14.120 回答