UIButton Scale Animation doesn't work anymore

357 views Asked by At

Thanks for the help so far !

This is my problem :

I have a method for my animation :

-(void) animateButtonDown {

// Animation for cornerRadius
[self.playStopButton setTitle:@"" forState: UIControlStateNormal];
CABasicAnimation *morph = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
morph.fromValue = @42.5;
morph.toValue = @0;
morph.duration = 0.5;
[self.playStopButton.layer addAnimation:morph forKey:@"morph"];
playStopButton.layer.cornerRadius = 0;

//Animation for scale and color
playStopButton.transform = CGAffineTransformMakeScale(1,1);
[UIView beginAnimations:@"button" context:nil];
[UIView setAnimationDuration:0.5];
    playStopButton.transform = CGAffineTransformMakeScale(0.6,0.6);
    playStopButton.backgroundColor = UIColorFromRGBWithAlpha(0x000000,0.3);
[UIView commitAnimations]; }

The animation worked fine. Now the animation for transform the scale factor does not work anymore. It seems like the whole construct :

playStopButton.transform = CGAffineTransformMakeScale(1,1);
[UIView beginAnimations:@"button" context:nil];
[UIView setAnimationDuration:0.5];
    playStopButton.transform = CGAffineTransformMakeScale(0.6,0.6);
    playStopButton.backgroundColor = UIColorFromRGBWithAlpha(0x000000,0.3);
[UIView commitAnimations];

Does not work anymore. It jumps directly to (0.6,0.6)... This was first recognized with update to xCode 6.1.3.

I need a smooth scale transform animation with duration of 0.5.

I hope anyone can help me ?

1

There are 1 answers

1
Sujay On

Try with animation block, may be it will work

[UIView animateWithDuration:0.5 animations:^{
  playStopButton.transform = CGAffineTransformMakeScale(0.6,0.6);
  playStopButton.backgroundColor = UIColorFromRGBWithAlpha(0x000000,0.3);
}];