I’m trying to animate (fade in/out) a UILabel and I’m using the following code:
float newAlpha = 0.0;
//TODO:Check if the previous animation has finished
if(answer.alpha==0.0) {
newAlpha = 1.0;
} else if(answer.alpha==1.0) {
newAlpha = 0.0;
}
[UIView animateWithDuration:1.0 animations:^{
answer.alpha = newAlpha;
}];
Where the TODO comment is, I want to check if the previous animation has finished and if it hasn’t, exit the method. Is there some way of doing this?
UPDATE #1:
you need a variable in your class:
and then you can use the following way for the animation:
it must be work.
ORIGINAL
I’m always checking the subject of the animation in this case, like this: