I'm trying to animate a custom button using CGAffineTransformMakeScale as follows:
if (stateButton == 0) { //The button is gonna appear
self.selected = YES;
self.imageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
// animate it to the identity transform (100% scale)
self.imageView.transform = CGAffineTransformIdentity;
} completion:nil];
}
else if (stateButton ==1) { //The button is gonna disappear
self.imageView.transform = CGAffineTransformMakeScale(1, 1);
[UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
// decrease button
self.imageView.transform = CGAffineTransformMakeScale(.01, .01);
} completion:^(BOOL finished){
self.selected = NO;
}];
}
The button grows perfectly to the original size, however, i don't know the reason but when i click on the button to decrease it, it decreases from a size like 100% bigger than the original size to the original size, instead of beginning the decrease in the original size and achieve an scale of 0.01 as I indicated in the code.
Please help!!