0

I have a UIButton and I am using an animation to change its size in this way:

[UIView animateWithDuration:1.0
                      delay:0.0
                    options: UIViewAnimationCurveEaseInOut
                 animations:^{

                     OpenNoteVisible.frame = CGRectMake(20, 90, 260, 260);
                     [OpenNoteVisible.layer setCornerRadius:135.0f];

                 }
                 completion:^(BOOL finished){

                 }];

But while I do this I would like the corner radius to gradually increase from the original 40 to 135. The problem is that the app sets the radius immediately, without progressively changing it like done with the size of the button. How can I obtain that effect?

EDIT:

As @0xfffffff suggested, I tried using this code:

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.fromValue = [NSNumber numberWithFloat:10.0f];
animation.toValue = [NSNumber numberWithFloat:0.0f];
animation.duration = 1.0;
[animation.layer setCornerRadius:140.0];
[OpenNoteVisible.layer addAnimation:animation forKey:@"cornerRadius"];

But I am getting an error at the line [animation.layer setCornerRadius:140.0];

rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2014474
  • 1,117
  • 5
  • 19
  • 36
  • You're getting an error because `CABasicAnimation` doesn't have a layer property. You need to set the corner radius on the layer you're animating, i.e `[OpenNoteVisible.layer setCornerRadius:140.0]`. Also your `toValue` on the animation object needs to match this 140.0 value. – WDUK Aug 29 '13 at 12:46
  • @WDUK I tried that but it gives the same effect as the original animation... – user2014474 Aug 29 '13 at 12:49
  • actually I had to change even the from value. thanks @WDUK – user2014474 Aug 29 '13 at 12:51

0 Answers0