iphone - 使iOS中的过渡动画持续时间更长

标签 iphone ios animation transition

我有一个从 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/

相关文章:

iphone - iOS 5 Twitter Framework & completionHandler block - "Capturing ' self 在这个 block 中很可能导致保留周期”

ios - 您可以使用 Xcode 子项目在另一个 iOS 应用程序中运行一个 iOS 应用程序吗?

ios - iOS 中的词干提取 - 不适用于单个词

objective-c - 核心数据过度使用?

ios - 为什么 View Controller 有两个@interfaces?

javascript - JavaScript 中的 CSS3 关键帧

jquery - 具有 jQuery 宽度的 CSS 动画仍然可见 0%

iphone - 当 CGRect 是实例变量时如何获得对 CGRect 元素的赋值访问

iphone - 在编辑模式下防止 UITableView 默认行为

javascript - 图像闪烁及预防。正确的编码标准