Xcode 设置MKPolyline或MKPolylineView的动画
我不知道怎么做,甚至不知道是否有可能做到这一点,但我想在我的地图上动画蓝线连接两个点(A和B) 我已经阅读了一些教程,介绍了如何在地图上围绕一个点设置圆的动画,但是我无法设置直线的动画(Xcode 设置MKPolyline或MKPolylineView的动画,xcode,animation,calayer,mkoverlay,Xcode,Animation,Calayer,Mkoverlay,我不知道怎么做,甚至不知道是否有可能做到这一点,但我想在我的地图上动画蓝线连接两个点(A和B) 我已经阅读了一些教程,介绍了如何在地图上围绕一个点设置圆的动画,但是我无法设置直线的动画(MKPolyline) 这是我想用作MKPolyline UIImage *textImage = [UIImage imageNamed:@"lineImage.png"]; CGFloat textWidth = textImage.size.width; CGFloat textHeight =
MKPolyline
)
这是我想用作MKPolyline
UIImage *textImage = [UIImage imageNamed:@"lineImage.png"];
CGFloat textWidth = textImage.size.width;
CGFloat textHeight = 5.0f;
CALayer *textLayer = [CALayer layer];
textLayer.contents = (id)[textImage CGImage];
textLayer.frame = CGRectMake(10.0f, 215.0f, textWidth, textHeight);
CALayer *maskLayer = [CALayer layer];
// Mask image ends with 0.15 opacity on both sides. Set the background color of the layer
// to the same value so the layer can extend the mask image.
maskLayer.backgroundColor = [[UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.15f] CGColor];
maskLayer.contents = (id)[[UIImage imageNamed:@"mask.png"] CGImage];
// Center the mask image on twice the width of the text layer, so it starts to the left
// of the text layer and moves to its right when we translate it by width.
maskLayer.contentsGravity = kCAGravityCenter;
maskLayer.frame = CGRectMake(-textWidth, 0.0f, textWidth * 2, textHeight);
// Animate the mask layer's horizontal position
CABasicAnimation *maskAnim = [CABasicAnimation animationWithKeyPath:@"position.x"];
maskAnim.byValue = [NSNumber numberWithFloat:textWidth];
maskAnim.repeatCount = HUGE_VALF;
maskAnim.duration = 1.0f;
[maskLayer addAnimation:maskAnim forKey:@"slideAnim"];
textLayer.mask = maskLayer;
[self.view.layer addSublayer:textLayer];
是否可以在MKOverlayView
中以某种方式执行此操作