开发环境 iOS7 && Xcode 5:
LaunchImageTransition是负责绘制动画的uiviewcontroler
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
UIViewController* oldRootController =self.window.rootViewController;
LaunchImageTransition* launchViewController = [[LaunchImageTransitionalloc] initWithViewController:oldRootController
animation:UIModalTransitionStyleCrossDissolve
delay:3.0f];
launchViewController.view.backgroundColor = [UIColorredColor];
self.window.rootViewController = launchViewController;
return YES;
}
LaunchImageTransition.m 文件内容
@implementation LaunchImageTransition
- (id)initWithViewController:(UIViewController *)controller animation:(UIModalTransitionStyle)transition {
return [self initWithViewController:controller animation:transition delay:0.0];
}
- (id)initWithViewController:(UIViewController *)controller animation:(UIModalTransitionStyle)transition delay:(NSTimeInterval)seconds {
self = [super init];
if (self) {
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *launchImageFile = [infoDictionary objectForKey:@"UILaunchImageFile"];
NSString *launchImageFileiPhone = [infoDictionary objectForKey:@"UILaunchImageFile~iphone"];
if (launchImageFile != nil) {
[self.view addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:launchImageFile]]];
} else if (launchImageFileiPhone != nil) {
[self.view addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:launchImageFileiPhone]]];
} else {
[self.view addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]]];
}
[controller setModalTransitionStyle:transition];
[NSTimer scheduledTimerWithTimeInterval:seconds target:self selector:@selector(timerFireMethod:) userInfo:controller repeats:NO];
}
return self;
}
- (void)timerFireMethod:(NSTimer *)theTimer {
[self presentViewController:[theTimer userInfo] animated:YES completion:^(){
}];
}
@end