我有这个小动画问题,我被卡住了。我想显示两个动画,一个接一个(首先将卡片从按钮刷到中心,然后翻转它)。所以我使用 UIView.animate 方法中的完成来触发第二个动画,一旦第一个动画完成。但在模拟器中,它每次只显示第二个动画。有人可以帮忙吗?非常感谢
UIView.animate(withDuration: 1, delay: 0, options: .curveEaseOut, animations: {
let animation:CABasicAnimation = CABasicAnimation(keyPath: "position")
animation.fromValue = NSValue(cgPoint:CGPoint(x: self.imgBackOfTheCard.frame.midX, y: 1200))
animation.toValue = NSValue(cgPoint:CGPoint(x: self.imgBackOfTheCard.frame.midX, y: self.imgBackOfTheCard.frame.midY))
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
animation.duration = 1
self.imgBackOfTheCard.layer.add(animation, forKey: "position")
}, completion: { (finished: Bool) in
UIView.animate(withDuration: 1, delay: 1, options: .curveLinear, animations: {
let transitionOptionsLeft: UIView.AnimationOptions = [.transitionFlipFromLeft, .showHideTransitionViews]
UIView.transition(from: self.imgBackOfTheCard, to: self.imgFrontCard, duration: 1, options: transitionOptionsLeft, completion: nil)
})
})