Iphone 禁用按钮时淡入淡出图像

Iphone 禁用按钮时淡入淡出图像,iphone,objective-c,ios,xcode,Iphone,Objective C,Ios,Xcode,我有这个按钮,我想当你点击它,他将成为禁用,屏幕上的图像将淡出,当下一个图像将完成淡入,按钮将再次启用 我有以下代码: -(IBAction)showPrev:(id)sender { if (x != 0) { x=x-1; [self fadeOut]; imgLettersView.image = [imagesArray objectAtIndex:x]; [self fadeIn]; btn

我有这个按钮,我想当你点击它,他将成为禁用,屏幕上的图像将淡出,当下一个图像将完成淡入,按钮将再次启用

我有以下代码:

-(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;
}

对fadeIn方法进行以下调整:

-(void)fadeIn
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.2f];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(reEnableButton)];
    [self.imgLettersView setAlpha:1.0f];
    [UIView commitAnimations];
}
另外,将以下方法添加到同一控制器类中,就可以开始了:

- (void) reEnableButton {
    btnNext.enabled = YES;
    btnPrev.enabled = YES;
}