iPhone旋转时CALayer的自动旋转 [英] Autorotation of CALayer on iPhone rotation

查看:65
本文介绍了iPhone旋转时CALayer的自动旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIViewController,我在其中向视图层添加了CALayer子类:

I have a UIViewController where I am adding a CALayer subclass to the view's layer:

[self.view.layer addSublayer:myObject.backgroundLayer];

当我旋转设备时,视图会旋转,但是CALayer不会。它有点被分离到左侧,仍然处于纵向视图。

When I rotate the device, the view rotates, but the CALayer doesn't. It sort of gets shunted off to the left, still in portrait view.

是否有一种方法可以使子图层自动旋转,还是需要应用变换?

Is there a way to make sublayers rotate automatically or do I need to apply a transform?

推荐答案

您需要自己管理CALayer的轮换。我相信0,0会保留在同一位置,并且大小会更改为与新方向匹配,因此,如果您要自己做某事,则需要自己管理旋转变换的添加。

You need to manage the rotation of the CALayer yourself. I believe that 0,0 stays at the same place and that the size is changed to match the new orientation, so if you wanted to do something yourself, you'd need to manage the addition of the rotation transformation yourself.

这篇关于iPhone旋转时CALayer的自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆