I created an imageView with which I would like to display an error. I use animations to fade the image in / out. This is the code I use for the animation:
imageView.hidden = NO;
imageView.alpha = 0;
[UIView animateWithDuration:.25 animations:^{
imageView.alpha = 1;
} completion:^(BOOL finished) {
imageView.hidden = NO;
}];
imageView.alpha = 1;
[UIView animateWithDuration:.25 delay:4.5 options:0 animations:^{
imageView.alpha = 0;
} completion:^(BOOL finished) {
imageView.hidden = YES;
}];
So my image does fade out as it should but it does not fade in, why ever. Do you have an idea?
Try this. I normally put the additional animations within the completion block of the first animation. I tested this and it works for me. If this doesn't work, check to make sure your imageView
property is connected properly in your layout file.
imageView.hidden = NO;
imageView.alpha = 0.0f;
[UIView animateWithDuration:0.25f animations:^{
imageView.alpha = 1.0f;
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.25f delay:4.5f options:0 animations:^{
imageView.alpha = 0.0f;
} completion:^(BOOL finished) {
imageView.hidden = YES;
}];
}];