在MKMapView上复制像用户位置一样的辐射状圆圈



是否可以有像用户位置注释那样的辐射圆?自定义注解有其他颜色的辐射圆。如果没有,有什么方法可以让它工作吗?

看看这个。你可以用它做你想做的事。结合使用核心动画和子类化MKCircleViewMKOverlayView

http://yickhong-ios.blogspot.com/2012/04/animated-circle-on-mkmapview.html

可以创建一个UIView的自定义子类来做这个。一个有两个子层的UIView,一个用于中心球,一个用于扩展环。环层和球层可以通过子类化CALayer和重写drawwincontext来创建:所以你可以得到任何你想要的颜色。代码动画的环,使他们扩大和淡出的同时可以使用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];

最新更新