I recently stumbled upon a problem where I have a view that can be rotated by the user. During the rotation it should, however, be 10% larger (scaled up).
I want that scaling to be animated but the rotation to be be visible immediately since I set it without animation in the gesture recognizer's callback.
Question: Is it possible to update an CGAffineTransform
's rotation without intercepting the scale being animated, or is there no way around creating a wrapping view that gets scaled instead?
Edit:
I think a wrapper view for scaling would be the least error prone way.
If you desperately want to avoid that, you could try to create the scaling animation manually with an NSTimer. Maybe if you query the current transform value first and then modify it instead of replacing it by an independently created one (for the rotation and the scale), it could work.
I think an implicit UIView animation calculates all subsequent values in the beginning, so that would mess up your rotation.
Another way to go would be to lock the rotation while the scaling occurs. The downside is, that scaling and rotation wouldn't be simultaneously. Anyway you could create an iVar or property let's say rotationLocked
and do sth. like this:
- (void)handlePan:(UIPanGestureRecognizer *)gr
{
if (gr.state == UIGestureRecognizerStateBegan)
{
self.rotationLocked = YES;
[UIView animateWithDuration:.2 animations:^{
[self scaleView];
}completion:^{ self.rotationLocked = NO; };
}
if (gr.state == UIGestureRecognizerStateChanged)
{
if (!self.rotationLocked){
// do the rotation
}
if (gr.state == UIGestureRecognizerStateEnded)
{
// do something else
}