1方援、在圖片文件夾Assets.xcassets左側(cè)創(chuàng)建New Image Set庄撮,名字自己定
2、右鍵創(chuàng)建的文件點擊Show in Finder
3师倔、找到新建文件下的contents.json文件
4悔叽、復(fù)制以下內(nèi)容替換原cotents.json內(nèi)容并保存
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "splash_bgXSMax@3x.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"filename" : "splash_bg.png",
"idiom" : "iphone",
"scale" : "1x",
"subtype" : "retina4"
},
{
"filename" : "splash_bg@2x.png",
"idiom" : "iphone",
"scale" : "2x",
"subtype" : "retina4"
},
{
"filename" : "splash_bg@3x.png",
"idiom" : "iphone",
"scale" : "3x",
"subtype" : "retina4"
},
{
"filename" : "splash_bg55@3x.png",
"idiom" : "iphone",
"scale" : "3x",
"subtype" : "736h"
},
{
"filename" : "splash_bg47@2x.png",
"idiom" : "iphone",
"scale" : "2x",
"subtype" : "667h"
},
{
"filename" : "splash_bgXS@3x.png",
"idiom" : "iphone",
"scale" : "3x",
"subtype" : "2436h"
},
{
"filename" : "splash_bgXSMax@3x.png",
"idiom" : "iphone",
"scale" : "3x",
"subtype" : "2688h"
},
{
"filename" : "splash_bgXR@2x.png",
"idiom" : "iphone",
"scale" : "2x",
"subtype" : "1792h"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
5莱衩、回到項目工程中,點擊剛才創(chuàng)建的New Image Set會發(fā)現(xiàn)對應(yīng)的圖片規(guī)格娇澎,由于iPhone12目前沒有規(guī)格笨蚁,因此在universal中添加對應(yīng)尺寸的3x圖即可對應(yīng)通用適配
注意:添加完圖片后,刪除項目趟庄,關(guān)閉模擬器括细,clean一下Xcode,然后重新運行項目即可