我的一个视图控制器中有一些代码可以从一个视图滑动过渡到另一个视图:
-(void)transitionToNewView:(UIView*)newView
{
UIView *superView = [self.view superview];
[superView addSubview:newView];
newView.frame = superView.bounds;
[self.view removeFromSuperview];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[superView layer] addAnimation:animation forKey:@"keygoeshere"];
}
滑动过渡似乎工作正常,但除了滑动之外,我还看到新视图从空白屏幕淡入。我怀疑这是因为我正在向以前不存在的超级视图添加一个新视图。我想做的是同样的事情,但没有淡入。我该怎么做?