UIView perspective

2019-09-08 16:31发布

问题:

I've got an UIView and I want to add perspective to it. Basically I got 4 other views that the user will drag in order to create the perspective. I'd like to indicate 4 points where the UIView's corners will be. I investigated it and I figured out I have to use CALayer to do that, but I'm still no clearer on how to create this kind of transform on an iPhone. Any help, pointers or example code snippets would be really appreciated!

Thanks!

回答1:

Start off by taking a look at the pertinent documentation for CATransform3D. You will create such a transform that describes your perspective and set the CALayer's -transform property to it. (Note that this is distinct from the UIView's -transform which is a CGAffineTransform, not a CATransform3D.)

Come back with code if you still encounter difficulties. :-)