ios13開始捎迫,蘋果要求使用LaunchScreen.storyboard來設(shè)置啟動圖了匠抗。之前因?yàn)閱禹摫容^簡單,一張圖就可以了紊遵。拉不拉伸看不大出來账千。如果啟動圖內(nèi)容過多的話,就很明顯看到會有拉伸了暗膜,所以一張圖是不夠的匀奏。
-
在Assets里創(chuàng)建Image
image.jpeg -
直接將需要適配的不同尺寸的啟動圖到剛才創(chuàng)建的imageset中;
或者偷懶的話直接將原來LaunchImage.launchimage里面的json文件和啟動圖
image.jpeg
直接拖到新創(chuàng)建的imageset中覆蓋替換学搜。
image.jpeg -
如果不是直接從LaunchImage.launchimage拖json文件進(jìn)來的娃善,去編輯Contents.json文件,把圖中內(nèi)容
image.jpeg替換為如下的內(nèi)容,并根據(jù)你的具體情況瑞佩,修改一下下面內(nèi)容里面的對應(yīng)不用尺寸下的啟動圖片名
"idiom" : "iphone", "scale" : "1x" }, { "idiom" : "iphone", "filename" : "iPhone4.png", "scale" : "2x" }, { "idiom" : "iphone", "subtype" : "retina4", "scale" : "1x" }, { "idiom" : "iphone", "filename" : "iPhone5s.png", "subtype" : "retina4", "scale" : "2x" }, { "idiom" : "iphone", "filename" : "iPhone8P.png", "subtype" : "736h", "scale" : "3x" }, { "idiom" : "iphone", "filename" : "iPhone8.png", "subtype" : "667h", "scale" : "2x" }, { "idiom" : "iphone", "filename" : "IPhoneX.png", "subtype" : "2436h", "scale" : "3x" }, { "idiom" : "iphone", "filename" : "iPhone XS Max.png", "subtype" : "2688h", "scale" : "3x" }, { "idiom" : "iphone", "filename" : "iPhone XR.png", "subtype" : "1792h", "scale" : "2x" }```
-
然后在LaunchScreen.storyboard里直接拖入ImageView布局聚磺。并填入對應(yīng)的imageset名字。
image.jpeg
至此炬丸,適配基本就完成了瘫寝。如果你要確認(rèn)在不同機(jī)型上有沒有使用對應(yīng)的圖的話,可以在圖上做一下標(biāo)記,看看使用的圖是不是對應(yīng)的稠炬。如下圖
image.jpeg
啟動頁替換大概會有緩存的問題焕阿。替換后測試的話,記得多手動刪除app首启,多清理緩存捣鲸。
另外還能想到的做法,就是把啟動頁的內(nèi)容細(xì)分,當(dāng)做一個頁面而不是圖去做適配吧闽坡?