0

许多人使用这种方法在切换视图时添加动画。当我尝试在添加子视图时添加动画效果时,视图总是闪烁一次。原因是视图在开始时立即添加子视图,然后动画开始。

CATransition *transition = [CATransition animation];
transition.duration = 0.35;
transition.removedOnCompletion = NO;
transition.fillMode = kCAFillModeForwards;
transition.type = kCATransitionFade;
transition.subtype = kCATransitionFromBottom;
transition.delegate = self;
[[animationView layer] addAnimation:transition forKey:@"switchView"];
OtherViewController *otherController = [[OtherViewController alloc]init:cityID];
self.myOtherViewController = otherController;
[otherController release];
[self.view insertSubview:myOtherViewController.view atIndex:1];

出现问题的原因是什么?如何实现不使用flash加载新视图的动画?

4

1 回答 1

0

将fillMode修改为kCAFillModeBoth后,就可以了。

transition.fillMode = kCAFillModeForwards;

于 2012-06-19T06:22:30.970 回答