简体   繁体   中英

Detect rotation of subviews

I have a view containing several subviews. I can detect and let the user rotate just one subview or the containing view using UIRotationGestureRecognizer. But I would like to be able to rotate any square collection of subviews, like so:

Initial state:

初始状态

Rotating upper right square counter-clockwise

旋转右上角正方形

To get here

到这里

How can I achieve this behavior? How should I nest my view hierarchy?

Any pointers are appreciated :)

here's what I would do (pseudocode):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM