1、利用系统自带的LanuchSreen,每次启动程序时,都会自动启动自带的LanuchScreen.xib文件;当然,只有在Xcode6之后才有。。。
2、直接看代码:
3、启动程序的画面效果:
4、画面中的图片是百度上的,小清新。。。
5、代码解释:
//重新捕捉window,如果不加此代码,就没有效果了。。。
[self.window makeKeyAndVisible];
//将系统的LanuchScreen重新load过来,并且形成一个新的view(phLanuchView)
self.phLanuchView = [[NSBundle mainBundle ]loadNibNamed:@"LaunchScreen" owner:nil options:nil][0];
//调节位置
self.phLanuchView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
//在window上加上这个view
[self.window addSubview:self.phLanuchView];
//将图片add到phLanuchView上
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 50)];
NSString *str = @"http://img.xiaba.cvimage.cn/4e4f46dce5688376610009d2.jpg";
//使用SDWebImage加载
[imageView sd_setImageWithURL:[NSURL URLWithString:str] placeholderImage:[UIImage imageNamed:@"default"]];
[self.phLanuchView addSubview:imageView];
//放到window最前面
[self.window bringSubviewToFront:self.phLanuchView];
//不可能一直看图片的,记得用个定时器移除phLanuchView
[NSTimer scheduledTimerWithTimeInterval:20.0f target:self selector:@selector(removeLanuch) userInfo:nil repeats:NO];
6、额。。。Lanuch写错了,是Launch,算了。。不改了!