iOS LaunchImage 转LaunchScreen 2020.5.7

到2020年4月,上架APP的启动图必须使用launchscreen.storyboard,听说没有这个的不给通过审核了。赶紧更改一下,5月份要提交个新版本,这个不改其他新功能也提交不了。

各种查找,尝试。最终算是弄好了,就等提交审核了。具体办法如下:

1、添加LaunchScreen.storyboard文件:就是添加文件的流程。

2、准备几个全屏图片:就是之前的LaunchImage,可以直接拿来用。

3、在image.xcassets里面新建一个图片文件:mysplash

4、配置这个mysplash图片资源:右键到文件目录。准备这几个文件 如下图

iOS LaunchImage 转LaunchScreen 2020.5.7

5、配置Contents.json文件:把下面的内容贴进去就行

{

  "images" : [

    {

      "idiom" : "iphone",

      "scale" : "1x"

    },

    {

      "filename" : "[email protected]",

      "idiom" : "iphone",

      "scale" : "2x"

    },

    {

      "idiom" : "iphone",

      "scale" : "3x"

    },

    {

      "idiom" : "iphone",

      "scale" : "1x",

      "subtype" : "retina4"

    },

    {

      "filename" : "[email protected]",

      "idiom" : "iphone",

      "scale" : "2x",

      "subtype" : "retina4"

    },

    {

      "idiom" : "iphone",

      "scale" : "3x",

      "subtype" : "retina4"

    },

    {

      "filename" : "[email protected]",

      "idiom" : "iphone",

      "scale" : "3x",

      "subtype" : "736h"

    },

    {

      "filename" : "[email protected]",

      "idiom" : "iphone",

      "scale" : "2x",

      "subtype" : "667h"

    },

    {

      "filename" : "1125x2436.png",

      "idiom" : "iphone",

      "scale" : "3x",

      "subtype" : "2436h"

    },

    {

      "filename" : "1668x2224.png",

      "idiom" : "iphone",

      "scale" : "3x",

      "subtype" : "2688h"

    },

    {

      "filename" : "828x1792.png",

      "idiom" : "iphone",

      "scale" : "2x",

      "subtype" : "1792h"

    },

    {

      "filename" : "[email protected]",

      "idiom" : "ipad",

      "scale" : "1x"

    },

    {

      "filename" : "2048x2732.png",

      "idiom" : "ipad",

      "scale" : "2x"

    }

  ],

  "info" : {

    "author" : "xcode",

    "version" : 1

  }

}

6、删除image.xcassets里面的LaunchImage。(删不删好像都行,听说是优先使用LaunchScreen)

7、打开LaunchScree.storyboard,添加一个UIImageView控件。并配置为autolayout。上下左右边距都为零,并且参考物为Superview,也就是那4个约束 上下左右 都配置成 Superview的上下左右。然后,给这个控件配置mysplash。

iOS LaunchImage 转LaunchScreen 2020.5.7

 

8、项目配置:将LaunchScreen.storyboard设置为启动图,当然,新版的xcode已经不再支持LaunchImage了,因为下拉框没有这个选项了,只有LaunchScreen

iOS LaunchImage 转LaunchScreen 2020.5.7

9、一切就绪。clean之后,重新build,看看,如果不行(重启xcode,还不行只有重启电脑大法了),就重启看看,我用的是终极大法:重启电脑。ok了。