前后滑动动画

CAKeyframeAnimation* animation = [CAKeyframeAnimationanimationWithKeyPath:@"transform.translation.x"];

CGFloatcurrentTx =addShopImageView.transform.tx;

animation.delegate=self;

animation.duration=0.3;

animation.values=@[@(currentTx),@(currentTx +10),@(currentTx-8),@(currentTx +8),@(currentTx -5),@(currentTx +5),@(currentTx)];

animation.keyTimes=@[@(0),@(0.225),@(0.425),@(0.6),@(0.75),@(0.875),@(1)];

animation.timingFunction= [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];

[addShopImageView.layeraddAnimation:animationforKey:@"DSAddShopSnakeAnimation"];

推荐阅读更多精彩内容