检测子视图的旋转

时间:2013-02-28 18:49:17

标签: ios objective-c uikit

我有一个包含多个子视图的视图。我可以使用UIRotationGestureRecognizer检测并让用户只旋转一个子视图或包含视图。但我希望能够旋转任何方形的子视图集合,如下所示:

初始状态:

Initial state

逆时针旋转右上方

Rotating upper right square

到达这里

To get here

我该如何实现这种行为? 我应该如何嵌套我的视图层次结构?

赞赏任何指示:)

1 个答案:

答案 0 :(得分:0)

这就是我要做的事(伪代码):

when rotation recognized:
    create new_layer
    new_layer.bounds = union_rect( frames of tiles to be rotated )
    new_layer addSublayers:(tiles to be rotated)

while rotation in progress:
    new_layer.transform = CATransform3DMakeRotation( angle, 0, 0, 1 )

when rotation complete:
    (original view).layer addSublayers:(tiles to be rotated)
    (tiles to be rotated) rearrange after rotation