我想从上到下制作一个视图幻灯片。这不是什么大问题,我用这个CABasicAnimation
。问题是当我想删除视图。我使用这个动画。动画之后,查看位置重置
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"position"];
[animation setDelegate:self];
animation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.view.layer.position.x, 0 - self.view.bounds.size.height/2)];
animation.fromValue = [NSValue valueWithCGPoint:self.view.layer.position];
animation.autoreverses = NO;
animation.repeatCount = 0;
animation.duration = 0.25;
animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];
[self.view.layer addAnimation:animation forKey:@"moveX"];
其中动画视图完美。但是,动画结束后,我的观点再次出现。所以我增加了这一行:
[self.view removeFromSuperview];
它删除视图,但没有动画。所以我决定删除代码添加到该委托:
-(void) animationDidStop:(CAAnimation *) animation finished:(bool) flag
所以,现在的动画作品,在视图中消失,但有时,我可以看到的视图出现和消失快,就像是动画之后,视图出现,然后调用animationDidStop
委托,视图消失,显然这是可怕的。我究竟做错了什么?
为什么我没有看到?谢谢,这解决了我的问题。我认为这是一个错误,我不应该这样做,但至少它是有效的。 – carlos 2008-10-23 00:45:07