I have this button and I want when you click on it he will become disabled and the image on the screen will fade out, when the next image will finish to fade in, the button will be enabled again.
I have this code:
-(IBAction)showPrev:(id)sender
{
if (x != 0)
{
x=x-1;
[self fadeOut];
imgLettersView.image = [imagesArray objectAtIndex:x];
[self fadeIn];
btnNext.enabled = NO;
}
else
{
btnPrev.enabled = NO;
btnNext.enabled = YES;
}
lblshowx.text = [NSString stringWithFormat:@"%i",x];
}
-(void)fadeOut
{
btnNext.enabled = NO;
btnPrev.enabled = NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.2f];
[self.imgLettersView setAlpha:0.0f];
[UIView commitAnimations];
[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(fadeIn) userInfo:nil repeats:NO];
}
-(void)fadeIn
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.2f];
[self.imgLettersView setAlpha:1.0f];
[UIView commitAnimations];
btnNext.enabled = YES;
btnPrev.enabled = YES;
}
Make the following adjustments to your fadeIn method:
Also, add the following method to the same controller class, and you’re good to go: