最近在学习iOS开发,碰到一个设置启动图片的问题,怎么也搞不定,综合网上种种资料后Done,现在把完整过程写一下。
这里以建立一个空的Single View Application 为演示基础。
1.去除LaunchScreenFile的引用。

2.添加图片启动页



3.将预先准备好的要求的像素的PNG文件直接拖放进对应位置即可。

4.应用一下刚做好的图片源

5.OK,运行一下试试吧。
等等,怎么回事,一闪即过?这可不行啊,让它等上2s再进入主界面吧,在 AppDelegate.m 文件中对应位置中插入下面第5行代码
1 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2 // Override point for customization after application launch.
3
4 //停留2s再进主界面
5 [NSThread sleepForTimeInterval:2.0];
6
7 return YES;
8 }
设置的过程如图

6.好了,再运行一下看看

关于图片大小和格式的问题:
a.图片大小不能错,差一个像素都不行,虽然能拖过去,但编译时会报错,如图

b.PNG以外格式的图片,拖都拖不上去好吧...
最后放上几张例子中用到的图片吧:-D (请右键另存为)
2208x1242像素路飞.PNG
一张不符合分辨率的256X256PNG一张
一张不符合格式要求的JPG一张 |