ios - UIView animationWithDuration not working second when called twice -


i have created category on uitextfield allows animate between red , white color shown below:

@implementation uitextfield (additions)  -(void) flash {     [uiview animatewithduration:2.0 animations:^{          [self setbackgroundcolor:[uicolor redcolor]];      } completion:^(bool finished) {          [self setbackgroundcolor:[uicolor whitecolor]];     }];  }  @end 

i call this:

[self.paymenttextfield flash]; 

first time works , shows red background , switches white color. on second call not anything.

i'm not sure why doesn't work. tried , got same thing. however, since color doesn't animate, can instead:

self.backgroundcolor = [uicolor redcolor]; [self performselector:@selector(setbackgroundcolor:) withobject:[uicolor whitecolor] afterdelay:2]; 

this should give same look.


Comments