views:

35

answers:

2

I have a custom UIView which I named UIWheel that I am rotating upon TouchDown. This UIWheel has many UIViews which I would like to rotate at the opposite direction (so that they remain appearing upright even after rotation) .

How do I code to tell it to get all of the UIViews in the UIWheel and in TouchDown rotate in the opposite direction?

+1  A: 

Using the subviews property, iterate over each subview and rotate it exactly the way you rotate the outer view, but in the opposite direction.

Marcelo Cantos
Thank you so very very very very much! It worked perfectly!!!!!!!
Lily
A: 

As another option, you can move the part which you do want to rotate into its own subview, and just rotate that subview. It's a little counter-intuitive to rotate every object, then rotate a large number of them back into position.

Sam Dufel
Not 100% sure, but I'm guessing that the UIWheel has to own the other views, because the OP wants them to all go around the center together, but just wants them to remain upright as this is happening.
Marcelo Cantos
Ah, I see what you're saying - in that case, he still doesn't need to rotate them - a simple translation around the edge of the wheel would accomplish the same effect. Converting to polar coordinates, adjusting the angle, and converting back to cartesian would be a nice solution.
Sam Dufel
@Sam: You could do that, but it's more work, and hinders smooth transitions via CoreAnimation.
Marcelo Cantos