Here's a follow up to a previous question. My code below animates a square by scaling it and rotating it. It does this by making a rotation transform and adding a scale transform to it. That works fine. When it's done, it calls throbReset
. I used to have throbReset
just set self's transform
to a CGAffineTransformMakeScale
and that would unscale it, but would also unrotate it. So I tried starting with the current transform
and adding the unscale to it, but now it doesn't do anything (visible).
CGColorRef color = [[colorArray objectAtIndex:colorIndex] CGColor];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDidStopSelector:@selector(throbReset:context:)];
// [[self layer] setFillMode:kCAFillModeForwards]; // apparently not needed
CGAffineTransform xForm = CGAffineTransformMakeScale(2.0, 2.0);
xForm = CGAffineTransformRotate(xForm, M_PI / 4);
[self setTransform:xForm];
[[self layer] setBackgroundColor:color];
[UIView commitAnimations];
}
- (void)throbReset:(NSString *)animationID context:(void*)context {
NSLog(@"-%@:%s fired", [self class], _cmd);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
CGAffineTransform xForm = [self transform];
xForm = CGAffineTransformScale(xForm, 1.0, 1.0);
[self setTransform:xForm];
[UIView commitAnimations];
}