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

ios 启动动画的设置(闪屏)

2013-04-02 17:44 218 查看
Apple建议把启动图像做得和应用首页一样,看上去就像只是没有加载内容,譬如Settings和通讯录。这可以让用户以为已经看到了应用的界面,有信心很快就能看到内容,使用户产生应用已经迅速启动的错觉。也有很多应用使用精心制作的启动画面。这样做的问题是启动图像越是吸引注意,就越是让用户感觉启动缓慢用户甚至会以为你在故意拖延启动时间,只是为了展示自己的logo。所以并不推荐在启动动画多很多文章,这样给用户的体验会更好。详细可看《详解启动动画的商业需求和用户体验》http://oiamfish.diandian.com/post/2011-05-23/971773

在程序的入口类方法添加如下代码和方法:(加粗部分)

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

{

// Override point for customization after application launch.

[window addSubview:viewController.view];

[self.window makeKeyAndVisible];

splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];

splashView.image = [UIImage imageNamed:@"Default.png"];

[self.window addSubview:splashView];

[self.window bringSubviewToFront:splashView];

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration:2.0];

[UIView setAnimationTransition:UIViewAnimationTransitionNone forView: self.window cache:YES];

[UIView setAnimationDelegate:self];

[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];

splashView.alpha = 0.0;

splashView.frame = CGRectMake(-60, -85, 440, 635);

[UIView commitAnimations];

return YES;

}

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context

{

[splashView removeFromSuperview];

[splashView release];

}

换一种方法同样可以实现启动动画

self.connectionTimer=[NSTimer scheduledTimerWithTimeInterval:1.5 target:self selector:@selector(timerFired:) userInfo:nil repeats:NO];

[[NSRunLoop currentRunLoop] addTimer:self.connectionTimer forMode:NSDefaultRunLoopMode];

do{

[[NSRunLoop currentRunLoop]runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];

}while (!done);

-(void)timerFired:(NSTimer *)timer{

done = YES;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: