Search code examples
iosuitableviewcatransform3d

CATransform3D make view on top of view hierarchy


I'm using this transformation on a UITableView so I can recreate a "star wars effect" :

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -450;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform,
                                                          45 * M_PI / 165.0f, 1.0f, 0.0f, 0.0f);
rotationAndPerspectiveTransform = CATransform3DScale(rotationAndPerspectiveTransform, 1,
                                                         1.1, 1.1);
rotationAndPerspectiveTransform = CATransform3DTranslate(rotationAndPerspectiveTransform, 0, 0, 150);

It's ok but this transformation make the table view appears in front all other views in my controller. How can I make the table view stay at the bottom in the view hierarchy or make the others view above the table view. Thanks.


Solution

  • Have you tried zPosition on the tableView?

    tableView.layer.zPosition = -1;