Please go through the images.
Here is my project in Swift https://github.com/paulz/PerspectiveTransform that helps to calculate CATransform3D and includes Example app and playgrounds.
it can be used to animate CALayer transform property.
See wiki: https://github.com/paulz/PerspectiveTransform/wiki for details on constructing the matrix and other possible solutions.
Thank you for this question, it helped me to get started on my project knowing not only me have that problem!