Ios 同步cabasicanitation和UIView.animate使其相同

Ios 同步cabasicanitation和UIView.animate使其相同,ios,swift,uiview,Ios,Swift,Uiview,我试图创建一个动画,当用户拖动一个UIView然后释放它时,UIView返回到它的初始位置。问题是,我有CAShapeLayer连接到UIView,我想在UIView返回它的位置时保持连接CAShapeLayer使用CABasicAnimation,而UIView使用UIView.animate 如果我想要相同的EaseOut减速,如何在两者之间获得相同的定时?现在两个动画都离我们太远了 let destinations = self.myAspectDestination[se

我试图创建一个动画,当用户拖动一个
UIView
然后释放它时,
UIView
返回到它的初始位置。问题是,我有
CAShapeLayer
连接到
UIView
,我想在
UIView
返回它的位置时保持连接
CAShapeLayer
使用CABasicAnimation,而
UIView
使用
UIView.animate

如果我想要相同的EaseOut减速,如何在两者之间获得相同的定时?现在两个动画都离我们太远了

        let destinations = self.myAspectDestination[self.viewToDrag.accessibilityIdentifier!] ?? []
        for destination in destinations {
            if let link: CAShapeLayer = self.myAspects["\(self.viewToDrag.accessibilityIdentifier!):\(destination)"] {
                let newPath = UIBezierPath()
                newPath.move(to: (self.myPlanets[destination]?.center)!)
                newPath.addLine(to: self.originalLocation)
                let animation = CABasicAnimation(keyPath: "path")
                animation.duration = 1
                animation.isRemovedOnCompletion = true
                animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
                animation.fillMode = kCAFillModeBoth // keep to value after finishing
                animation.fromValue = link.path
                animation.toValue = newPath.cgPath
                animation.timingFunction = CAMediaTimingFunction(name: "easeInEaseOut")
                link.path = newPath.cgPath
                link.add(animation, forKey: animation.keyPath)
            }
        }

        UIView.animate(withDuration: 1, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveEaseOut, animations: {
            self.viewToDrag.center = self.originalLocation
        }) { (result) in
            self.viewToDrag = nil
        }

可能有用(重复?)。我的CAShapeLayers不是动画视图的子层。。。这里不一样。。。