0

我已经在另一个应用程序中实现了这段代码,效果很好。现在,相同的代码在这里不起作用(我正在导入 QuartzCore 框架)......调用了日志消息。有人可以帮我吗?提前致谢。这是我的代码:

- (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!");
}
4

1 回答 1

1

移动:

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

以下:

    [window makeKeyAndVisible];

您正在显式创建动画,但您正在应用动画“之前”,您希望将子视图添加到窗口。通过将其放置在下方,您可以告诉窗口您要为子视图的位置设置动画。

于 2012-01-03T03:33:23.327 回答