每个UIBezierPath移动UIView [英] Move UIView per UIBezierPath

查看:92
本文介绍了每个UIBezierPath移动UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIBezierPath 绘制了这个

我希望红点在蓝色路径上无限地移动(从右到左,从左到右)

And I want the red point to move on the blue path infinitely (from right to left, from left to right)

我该怎么做?

推荐答案

您可以使用 CAKeyFrameAnimation 。将路径分配给动画对象的 path 属性,然后在视图层上运行动画。

You can use CAKeyFrameAnimation. Assign your path to the path property of the animation object, then run the animation on the view's layer.

编辑

一些提示:

let path = ... // the UIBezierPath
let animation = CAKeyFrameAnimation()
animation.path = path.CGPath
animation.calculationMode = kCAAnimationPaced // This give the animation an even pace
animation.repeatCount = HUGE // This makes the animation repeat forever

viewToAnimation.layer.addAnimation(animation, forKey: nil)

这篇关于每个UIBezierPath移动UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆