我编写了一个自定义 UITableViewCell - 图像视图、按钮和三个标签,现在我正在尝试向它添加一些动画。因此,一旦我点击按钮,它就会消失,并且微调器会替换按钮。两秒钟后,单元格被红色覆盖,随着单元格的子视图淡入,然后指示器被移除,红色覆盖层开始淡出。我之前删除的按钮也会淡入。
(我无法用更好的方式表达它:P)
方法是:
-(void)rentButtonPressed:(id)sender
{
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
    [indicator startAnimating];
    indicator.center = self.rentButton.center;
    [UIView animateWithDuration:0.2
                     animations:^{self.rentButton.alpha = 0.0;}
                     completion:^(BOOL finished){
                         [self.rentButton removeFromSuperview];
                         [self addSubview:indicator];
                     }
     ];
    UIView *overlay = [[UIView alloc] initWithFrame:self.backgroundImage.frame];
    overlay.alpha = 0.0;
    overlay.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:overlay];
    [UIView animateWithDuration:0.4
                          delay:2.0
                        options:UIViewAnimationCurveEaseInOut
                     animations:^{
                             [indicator removeFromSuperview];
                             overlay.alpha = 0.4;
                         }
                    completion:^(BOOL finished){
                        [UIView animateWithDuration:0.4
                                        animations:^{ overlay.alpha = 0.0; }
                                        completion:^(BOOL finished)
                                        {
                                            [overlay removeFromSuperview];
                                        }
                        ];
                        [self.contentView addSubview:self.rentButton];
                        [UIView animateWithDuration:0.4 animations:^{ self.rentButton.alpha = 1.0;}];
                        [self.delegate didTryToRentMovieAtCell:self];
                    }
    ];
}
所以代码确实淡出按钮,用微调器替换它并淡入红色覆盖层。问题是,红色覆盖层并没有消失,而是与按钮一样消失,而不是淡入,它只是出现。