Reputation: 154
I have a view that slides up from the bottom of the screen when the user swipes up and when this happen a little arrow is supposed to rotate so that it is now pointing downwards. In a similar fashion, when the view is slid away to the bottom of the screen, the arrow should rotate again so that it points upwards. Ideally, I would like to call the same method every time the view slides in or out to rotate the arrow 180 degrees. Right now I am using:
[UIView animateWithDuration:.5 animations:^{
viewToBeRotated.transform = CGAffineTransformMakeRotation(M_PI);
}];
This works fine the first time but then doesn't do anything on further method calls, any pointers on how to do do this correctly?
Upvotes: 0
Views: 113
Reputation: 2107
When you set a transform on a view you erase previous transform. To have multiple transforms applied to one view at the same time you must "add" them. Each CGAffineTransformMake{Rotation/Scale/etc} has an equivalent which allows you to "add" a transform to another one.
To resolve your issue you can use the following :
self.iv.transform = CGAffineTransformRotate(self.iv.transform, M_PI);
Upvotes: 3