在 iOS 12 beta 12 下的 Swift 4.2 中,我想获取我在CAKeyframeAnimation
.
动画的代码是这样的:
@IBOutlet weak var dot: UIImageView!
func animateDot() {
// Oval path.
let ovalWidth = UIScreen.main.bounds.width * 0.7
let ovalHeight = UIScreen.main.bounds.height * 0.75
let ovalPath = UIBezierPath(ovalIn: CGRect(x: -ovalWidth / 2 , y: -ovalHeight / 2, width: ovalWidth, height: ovalHeight))
let orbit = CAKeyframeAnimation(keyPath: "position")
orbit.path = ovalPath.cgPath
orbit.duration = CFTimeInterval(2.5)
orbit.isAdditive = true
orbit.repeatCount = 6
orbit.calculationMode = kCAAnimationPaced
orbit.rotationMode = kCAAnimationRotateAuto
self.dot.layer.add(orbit, forKey: "orbit")
}
我的问题是:一旦启动并运行,如何在 Swift 中查询动画以获取点中心的当前屏幕 xy?