有些项目需要自己手动设计启动画面的方式,如图片的切换,给启动画面添加文本等;
首先,启动画面的图片切换,一般做法是添加一个滑动界面,把图片放进界面,启动后跳到该界面;这样就可以实现滑动界面的启动画面。
添加文本的启动界面,可以和上面的一样方法;不过还有一个简单的方法,代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
//splashView在.h中定义
_splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)];
_splashView.image = [UIImage imageNamed:@"Default.png"];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(60, 200, 200, 30)];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = @"welcome";
[_splashView addSubview:label];
[self.window addSubview:_splashView];
[self.window bringSubviewToFront:_splashView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.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];
}