Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 如何旋转CALayer支持的NSView子类_Cocoa_Core Animation_Rotation_Calayer_Nsview - Fatal编程技术网

Cocoa 如何旋转CALayer支持的NSView子类

Cocoa 如何旋转CALayer支持的NSView子类,cocoa,core-animation,rotation,calayer,nsview,Cocoa,Core Animation,Rotation,Calayer,Nsview,我有一个自定义的NSView子类,我想用核心动画制作它的动画。我已经(没有CA)使用NSView的setFrameOrigin和setFrameRotation方法设置了这些视图的位置和旋转。然而,无论我做什么,一旦我在视图中添加了一层背景,我就无法让它们旋转 我尝试过使用NSView的setFrameRotation和SetFrameCenter Rotation方法。后者稍微移动视图,但不旋转其内容。前者没有效果。将CATTransformM3dRotate创建的CATTransformM3

我有一个自定义的NSView子类,我想用核心动画制作它的动画。我已经(没有CA)使用NSView的setFrameOrigin和setFrameRotation方法设置了这些视图的位置和旋转。然而,无论我做什么,一旦我在视图中添加了一层背景,我就无法让它们旋转

我尝试过使用NSView的setFrameRotation和SetFrameCenter Rotation方法。后者稍微移动视图,但不旋转其内容。前者没有效果。将CATTransformM3dRotate创建的CATTransformM3D应用于视图的图层也没有效果


我觉得问这个问题有点傻,因为这似乎是件容易的事情,但就我的一生而言,我不知道如何让它起作用。有人,请让我拍一下我的额头,因为这太容易了。:)

结果表明,superview也需要层备份才能正常工作。做出改变可以解决问题。

如果你不再问问题,你可以将自己的答案标记为正确。