AppDelegate中的CATransition - didFinishLaunchingWithOptions

时间:2011-06-15 19:29:32

标签: iphone catransition

我已在其他应用中实施此代码,效果很好。现在,相同的代码在这里工作(我导入QuartzCore framewok)...调用日志消息 IS 。有人可以帮帮我吗?提前致谢。这是我的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.
    [NSThread sleepForTimeInterval:1.5];

    CATransition *transition = [CATransition animation];
    transition.delegate = self;
    transition.duration = 1.5;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionFade;

    [[window layer] addAnimation:transition forKey:nil];

    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];

    return YES;
}

- (void)animationDidStop:(CAAnimation *)theAnimation finished: (BOOL)flag
{
    NSLog(@"Animation did stop!");
}

1 个答案:

答案 0 :(得分:1)

移动:

    [[window layer] addAnimation:transition forKey:nil];

下面:

    [window makeKeyAndVisible];

您明确地创建了动画,但是您要将动画“之前”应用于要将子视图添加到窗口。通过将其放在下面,您可以告诉Window您要为子视图的位置设置动画。