如何使UIView遵循路径

时间:2019-01-18 16:27:02

标签: ios swift uiviewanimation ios-animations

我有一个UIBezierPath,我希望uiview遵循贝塞尔曲线和曲线的路径

我尝试创建UIBezierPath代码,并尝试使用链式动画使用贝塞尔曲线路径点更改视图的位置,但它以方形动画而不是弯曲运动的形式出现

UIView.animateKeyframes(withDuration: 0.4, delay: 0, options: [], animations: {
        UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.3, animations: {
            self.rectV.transform = CGAffineTransform(scaleX: 1.5, y: 1.5)
            self.rectV.center = CGPoint(x: 24.5, y: 49.5)
        })
        UIView.addKeyframe(withRelativeStartTime: 0.2, relativeDuration: 0.1, animations: {
            self.rectV.center = CGPoint(x: 94.5, y: 49.5)
        })

    }, completion: nil)

结果显示为四角形的动画而不是弯曲的动画

0 个答案:

没有答案