<span style="font-size:18px;"></span><pre name="code" class="objc"><span style="font-size:18px;"> CAKeyframeAnimation *keyFrame = [CAKeyframeAnimation animationWithKeyPath:@"position"]; //设置各个关键帧位置 keyFrame.values = @[[NSValue valueWithCGPoint:CGPointMake(124, 80)], [NSValue valueWithCGPoint:CGPointMake(119, 80)], [NSValue valueWithCGPoint:CGPointMake(129, 80)], [NSValue valueWithCGPoint:CGPointMake(119, 80)], [NSValue valueWithCGPoint:CGPointMake(129, 80)], [NSValue valueWithCGPoint:CGPointMake(119, 80)], [NSValue valueWithCGPoint:CGPointMake(129, 80)], [NSValue valueWithCGPoint:CGPointMake(124, 80)]]; //淡入淡出效果 keyFrame.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; //动画持续时间 keyFrame.duration = 0.5; //恢复到最初位置 imageView.layer.position = CGPointMake(524, 80); //密码输入框图层加入动画 [imageView.layer addAnimation:keyFrame forKey:@"keyFrame"]; </span>
CAKeyframeAnimation实现晃动
最新推荐文章于 2020-04-02 15:09:58 发布