以下是我用于动画的代码:
WhatIsCTTView *whatIsCTTView = [[WhatIsCTTView alloc] initWithNibName:@"WhatIsCTTView" bundle:nil];
UIView *currentView = self.view;
UIView *theWindow = [currentView superview];
UIView *newView = whatIsCTTView.view;
[currentView removeFromSuperview];
[theWindow addSubview:newView];
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToCTTView"];
非常感谢任何帮助,
谢谢,
马特
编辑:
我发现了如何解决这个问题,只需添加一行
即可“newView.frame = CGRectMake(0,20,320,460);”
将新的子视图添加到屏幕后,确保将其放置在正确的位置。看到这个问题(http://stackoverflow.com/questions/3952483/iphone-addsubview-show-view-too-high-up-how-do-i-move-to-down)我得到了答案。
马特