我有一个从 UIViewController 到 UITabBarViewController 的转换,转换工作完美,但所需的时间太快,无法欣赏效果。所以我想知道是否有办法让这个过渡动画持续更长时间?
这是我的 AppDelegate.m
@implementation AppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
@synthesize LoadingViewController = _LoadingViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.LoadingViewController;
[self.window addSubview:tabBarController.view];
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeView) userInfo:nil repeats:NO];
[self.window makeKeyAndVisible];
return YES;
}
-(void)changeView{
self.tabBarController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self.window.rootViewController presentModalViewController:self.tabBarController animated:YES];
}
这段代码在我的两个 Controller 之间进行转换。首先是我的 ViewController,2 秒后是我的 TabBarViewController。但正如我所说,这个动画进展得太快了。
最佳答案
使用此代码...
-(void)changeView{
// self.tabBarController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.5];// increase time duration with your requirement
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
kCAMediaTimingFunctionEaseInEaseOut]];
[[self.window layer] addAnimation:animation forKey:@"transitionViewAnimation"];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
}
关于iphone - 使iOS中的过渡动画持续时间更长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13833145/