Question

Many people use this method to add animation on switching views. When I try to add animation effect on adding a subview, the view always flash once。 The reason is that the view add subview immediately at the beginning, after that, the animation starts.

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];

What's the reasons of problem? How to implement the animation of loading new view without flash?

Was it helpful?

Solution

After modified fillMode to kCAFillModeBoth, it works.

transition.fillMode = kCAFillModeForwards;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top