我写了一个自定义的UITableViewCell - 图像视图,按钮和三个标签,现在我正试图给它添加一些动画。所以一旦我点击按钮,它就会消失,微调代替按钮。两秒钟后,细胞被红色覆盖,随着细胞的子视图淡入,指示器被移除,红色覆盖层开始消退。还有我以前删除按钮淡入回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];
}
];
}
因此,代码不会淡出按钮,将其替换为微调框并淡入红色覆盖层。问题是,红色覆盖层不会消失,而是与按钮一样消失,而不是消失,它刚刚出现。
不,这不会帮助下,这个问题”不是个t时间,它的事实是它们(视图)不会在完成处理器动画中淡入淡出。 – foFox
对不起@foFox误解了你的问题。检查我更新的答案,看看是否有帮助。 – jal72088