是否可以像用户位置注释一样使用辐射圈。因此,自定义注释具有其他颜色的辐射圆。如果没有,那么有什么方法可以让它发挥作用吗?
答案 0 :(得分:4)
检查一下。你可以用它来做你需要的。结合使用核心动画和子类化MKCircleView
或MKOverlayView
。
http://yickhong-ios.blogspot.com/2012/04/animated-circle-on-mkmapview.html
答案 1 :(得分:2)
可以创建UIView的自定义子类来执行此操作。 UIView有两个子层,一个用于中心球,另一个用于扩展环。可以通过继承CALayer并覆盖drawInContext来创建环层和球层:因此您可以获得所需的任何颜色。设置动画环以使它们同时扩展和淡出的代码可以使用这样的CAAnimationGroup:
// expand the ring from the ball size to the ring's max size
CABasicAnimation *sizeAnim = [CABasicAnimation animationWithKeyPath:@"bounds"];
sizeAnim.fromValue = [NSValue valueWithCGRect:ballBounds];
sizeAnim.toValue = [NSValue valueWithCGRect:ringBoundsMax];
sizeAnim.duration = kRingExpansionTime;
// fade out the ring part way thru the animation
CABasicAnimation* alphaAnim = [CABasicAnimation animationWithKeyPath:@"opacity"];
alphaAnim.fromValue = [NSNumber numberWithFloat:1];
alphaAnim.toValue = [NSNumber numberWithFloat:0];
alphaAnim.beginTime = kRingExpansionTime * 0.7f; // start part way thru
alphaAnim.duration = kRingExpansionTime - alphaAnim.beginTime;
CAAnimationGroup* group = [CAAnimationGroup animation];
group.duration = kRingExpansionTime;
group.repeatCount = HUGE_VALF; // repeat forever
group.animations = [NSArray arrayWithObjects:sizeAnim, alphaAnim, nil];
[ringLayer addAnimation:group forKey:nil];