private func flyOut() {
matchedButtons.forEach { (card) in
let index = self.matchedButtons.index(of: card)!
UIViewPropertyAnimator.runningPropertyAnimator(withDuration: 5.0, delay: 0.0, options: [UIViewAnimationOptions.showHideTransitionViews, .beginFromCurrentState], animations: {
card.transform = CGAffineTransform(rotationAngle: (2 * CGFloat.pi).arc4random)
let randomAngle = (2 * CGFloat.pi).arc4random
//card.frame = self.cardViews[index].frame.offsetBy(dx: self.explodeR * sin(randomAngle), dy: self.explodeR * cos(randomAngle))
print(sin(randomAngle))
self.view.addSubview(card)
}, completion: { finished in
let snapBehavior = UISnapBehavior(item: card, snapTo: self.setButton.frame.origin)
self.animator.addBehavior(snapBehavior)
UIViewPropertyAnimator.runningPropertyAnimator(withDuration: 5.0, delay: 1.0, options: .transitionFlipFromLeft, animations: {
card.isFaceUp = false
}, completion: { (position) in
card.removeFromSuperview()
})
})
}
matchedButtons.removeAll()
}
Plan: This animation rotates the cards (sort of like some wind **** effect) and then snap to a new location and flip the card down.
Reality: It only does the rotation and then after it is done the card goes disappeared immediatly. 😟
Please help a brother out here, thanks in front.