GMSMarker opacity animation not repeating

谁说胖子不能爱 提交于 2019-12-03 14:27:30

My solution was to add a delegate to the animation:

CABasicAnimation *blink = [CABasicAnimation animationWithKeyPath:@"opacity"];
blink.fromValue = [NSNumber numberWithFloat:1.0];
blink.toValue = [NSNumber numberWithFloat:0.0];
blink.duration = 1.5;
[blink setDelegate:self];
[placeMarker.layer addAnimation:blink forKey:@"blinkmarker"];

And then when the animation has finish I get a callback and add it again:

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
    if (flag) {
        CABasicAnimation *blink = [CABasicAnimation animationWithKeyPath:kGMSMarkerLayerOpacity];
        blink.fromValue = [NSNumber numberWithFloat:1.0];
        blink.toValue = [NSNumber numberWithFloat:0.0];
        blink.duration = 1.5;
        [blink setDelegate:self];
        [placeMarker.layer addAnimation:blink forKey:@"blinkmarker"];
    }
}

I had to do this since the GMSMarkerLayer does not care about repeating the animation. I tried reusing the animation in the callback and adding it again but that did not work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!