Despite all my best efforts, I can't figure out how to do a full cycle rotation animation of a UIView using CATransform3DRotate from left to right. Kindly note that I can already rotate it 360 degree with CABasicAnimation, but without CATransform3DRotate. However, I want to use .m34 transform for perspective depth. Solutions involving UIView.animate/transitions are not helpful in what I am trying to accomplish. Any help is much appreciated.
Edit: I searched far and wide in Stackoverflow and other places, but didn't find anything that describes how to do 360 rotation with CATransform3DRotate. Calling top guns out there for help as this is a question that does not seem to have been answered before. Thanks!
Here is the code that rotates UIView 180 degree.
var transform = CATransform3DIdentity
transform.m34 = 1.0 / -200.0
let animation = CABasicAnimation(keyPath: "transform")
animation.toValue = CATransform3DRotate(transform, CGFloat( Double.pi), 0, 1, 0)
animation.duration = 0.8
animation.beginTime = 0.0
animation.fillMode = .forwards
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
cardView.layer.add(animation, forKey: "360flip")