How to rotate a subclass of NSView running CALayer

I have a custom subclass of NSView that I want to animate with Core Animation. I already (without CA) set the position and rotation of these views using the NSView setFrameOrigin and setFrameRotation methods. However, no matter what I do, as soon as I add a layer that supports the views, I cannot make them rotate.

I tried using the NSView methods setFrameRotation and setFrameCenterRotation. The latter moves the view a bit, but does not rotate its contents. The first has no effect. Applying CATransform3D, created by CATransform3DRotate, to the view level also has no effect.

I feel a little silly asking this question because it seems like it should be easy, but for life I can't figure out how to make it work. Someone please make me pat me on the forehead how easy it is. :)

+3
source share
1 answer

It turns out that in order for this to work, the supervisor also needed the support of the layers. This change has changed him.

+7
source

Source: https://habr.com/ru/post/1715863/


All Articles