-2

I have a simple UIButton that i want to change its image with animation. What happens is that it changes right a way, without delay or animation :

  [UIView animateWithDuration:1.5
                          delay:2.0
                        options: UIViewAnimationOptionCurveEaseInOut
                     animations:^{

                             [button setImage:darkCellimg forState:UIControlStateNormal];
                     }
                     completion:^(BOOL finished)
     {

     }];
Curnelious
  • 1
  • 16
  • 76
  • 150
  • 1
    possible duplicate of [fade between two UIButton images](http://stackoverflow.com/questions/16801948/fade-between-two-uibutton-images) – Rick Jan 11 '15 at 14:04
  • no its not . that answer is not solving the real problem/question . – Curnelious Jan 11 '15 at 14:15
  • As mentioned in the answer below, this is not possible. Hence the answer is "This can't be done" and the question is a duplicate. – Rick Jan 12 '15 at 12:03

1 Answers1

3

A button's image is not an animatable property, that's why you see an immediate application of a new value. Please see the list of animatable properties here

Nikolay Mamaev
  • 1,474
  • 1
  • 12
  • 21
  • i have the same requirement. There must be a way – Abdul Yasin Mar 08 '17 at 13:05
  • 1
    @AbdulYasin There is a way - implement your own UIButton subclass, provide a method for manual animated change of a button image (e.g. animate old image's alpha from 1 to 0, then replace the image with a new one, which has initial alpha 0, and then animate new image's alpha from 0 to 1). As an alternative, you may want to create a CALayer with animatable property, see https://developer.apple.com/library/content/samplecode/sc2284/Introduction/Intro.html – Nikolay Mamaev Mar 10 '17 at 10:21