您的位置:首页 > 移动开发

iOS App启动动画

2014-08-20 15:31 302 查看
开发环境 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: