概述
使用ionic命令肤晓,會(huì)自動(dòng)在resources文件夾下創(chuàng)建已添加的平臺(tái)名稱的文件夾耀盗,如:android,其中會(huì)自動(dòng)將圖片進(jìn)行縮放房匆、裁剪耸成,生成不同分辨率的圖片,并在config.xml中添加相應(yīng)內(nèi)容浴鸿。
操作步驟
1.在項(xiàng)目的根目錄下創(chuàng)建resources文件夾井氢。
2.在文件夾中都放入icon.png(應(yīng)用圖標(biāo),最小192x192px岳链,不帶圓角)花竞,splash.png(啟動(dòng)屏幕,最小2208x2208px宠页,中間區(qū)域1200x1200px)(可以是png左胞、psd、ai)
3.在cmd中進(jìn)入項(xiàng)目所在文件夾執(zhí)行:
ionic resources --icon //只會(huì)生成圖標(biāo)
ionic resources --splash //只會(huì)生成閃屏
ionic resources //同時(shí)生成圖標(biāo)及閃屏
生成結(jié)果
執(zhí)行結(jié)果
ionic resources
Ionic icon and splash screen resources generator
uploading icon.psd...
uploading splash.psd...
icon.psd (192x192) upload complete
splash.psd (2208x2208) upload complete
generating splash android drawable-port-xxxhdpi-screen.png (1280x1920)...
generating splash android drawable-port-xxhdpi-screen.png (960x1600)...
generating splash android drawable-port-xhdpi-screen.png (720x1280)...
splash android drawable-port-xhdpi-screen.png (720x1280) generated
generating splash android drawable-port-hdpi-screen.png (480x800)...
splash android drawable-port-xxxhdpi-screen.png (1280x1920) generated
generating splash android drawable-port-mdpi-screen.png (320x480)...
splash android drawable-port-xxhdpi-screen.png (960x1600) generated
generating splash android drawable-port-ldpi-screen.png (240x320)...
splash android drawable-port-mdpi-screen.png (320x480) generated
generating splash android drawable-land-xxxhdpi-screen.png (1920x1280)...
splash android drawable-port-hdpi-screen.png (480x800) generated
generating splash android drawable-land-xxhdpi-screen.png (1600x960)...
splash android drawable-port-ldpi-screen.png (240x320) generated
generating splash android drawable-land-xhdpi-screen.png (1280x720)...
splash android drawable-land-xxxhdpi-screen.png (1920x1280) generated
generating splash android drawable-land-hdpi-screen.png (800x480)...
splash android drawable-land-xxhdpi-screen.png (1600x960) generated
generating splash android drawable-land-mdpi-screen.png (480x320)...
splash android drawable-land-xhdpi-screen.png (1280x720) generated
generating splash android drawable-land-ldpi-screen.png (320x240)...
splash android drawable-land-mdpi-screen.png (480x320) generated
generating icon android drawable-xxxhdpi-icon.png (192x192)...
splash android drawable-land-hdpi-screen.png (800x480) generated
generating icon android drawable-xxhdpi-icon.png (144x144)...
icon android drawable-xxhdpi-icon.png (144x144) generated
generating icon android drawable-xhdpi-icon.png (96x96)...
icon android drawable-xxxhdpi-icon.png (192x192) generated
generating icon android drawable-hdpi-icon.png (72x72)...
splash android drawable-land-ldpi-screen.png (320x240) generated
generating icon android drawable-mdpi-icon.png (48x48)...
icon android drawable-hdpi-icon.png (72x72) generated
generating icon android drawable-ldpi-icon.png (36x36)...
icon android drawable-mdpi-icon.png (48x48) generated
splash ios Default~iphone.png (320x480) generated
generating splash ios Default@2x~iphone.png (640x960)...
icon android drawable-xhdpi-icon.png (96x96) generated
generating splash ios Default-Portrait~ipad.png (768x1024)...
icon android drawable-ldpi-icon.png (36x36) generated
generating splash ios Default-Portrait@2x~ipad.png (1536x2048)...
splash ios Default-Portrait~ipad.png (768x1024) generated
generating splash ios Default-Landscape~ipad.png (1024x768)...
splash ios Default@2x~iphone.png (640x960) generated
generating splash ios Default-Landscape@2x~ipad.png (2048x1536)...
splash ios Default-Landscape~ipad.png (1024x768) generated
generating splash ios Default-Landscape-736h.png (2208x1242)...
splash ios Default-Portrait@2x~ipad.png (1536x2048) generated
generating splash ios Default-736h.png (1242x2208)...
splash ios Default-Landscape@2x~ipad.png (2048x1536) generated
generating splash ios Default-667h.png (750x1334)...
splash ios Default-736h.png (1242x2208) generated
generating splash ios Default-568h@2x~iphone.png (640x1136)...
splash ios Default-Landscape-736h.png (2208x1242) generated
generating icon ios icon-small@3x.png (87x87)...
icon ios icon-small@3x.png (87x87) generated
generating icon ios icon-small@2x.png (58x58)...
splash ios Default-667h.png (750x1334) generated
generating icon ios icon-small.png (29x29)...
icon ios icon-small@2x.png (58x58) generated
generating icon ios icon-76@2x.png (152x152)...
splash ios Default-568h@2x~iphone.png (640x1136) generated
generating icon ios icon-76.png (76x76)...
icon ios icon-small.png (29x29) generated
icon ios icon-72@2x.png (144x144) generated
icon ios icon-72.png (72x72) generated
generating icon ios icon-60@3x.png (180x180)...
icon ios icon-76@2x.png (152x152) generated
generating icon ios icon-60@2x.png (120x120)...
icon ios icon-76.png (76x76) generated
generating icon ios icon-60.png (60x60)...
icon ios icon-60.png (60x60) generated
generating icon ios icon-50@2x.png (100x100)...
icon ios icon-60@2x.png (120x120) generated
generating icon ios icon-50.png (50x50)...
icon ios icon-60@3x.png (180x180) generated
generating icon ios icon-40@2x.png (80x80)...
icon ios icon-50.png (50x50) generated
generating icon ios icon-40.png (40x40)...
icon ios icon-40@2x.png (80x80) generated
generating icon ios icon@2x.png (114x114)...
icon ios icon-40.png (40x40) generated
generating icon ios icon.png (57x57)...
icon ios icon-50@2x.png (100x100) generated
icon ios icon.png (57x57) generated
icon ios icon@2x.png (114x114) generated
坑洞說(shuō)明:
- 執(zhí)行以上命令時(shí)需在聯(lián)網(wǎng)下進(jìn)行
- 生成操作由服務(wù)器完成后下載到本地举户,經(jīng)常會(huì)因?yàn)榫W(wǎng)絡(luò)太慢導(dǎo)致生成失敗烤宙,一般我都會(huì)選擇移動(dòng)4G熱點(diǎn)下完成此操作
生成后的config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><widget id="com.ild.qos" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>qos</name> <description> An Ionic Framework and Cordova project. </description> <author email="you@example.com" > Your Name Here </author> <content src="index.html"/> <access origin="*"/> <preference name="webviewbounce" value="false"/> <preference name="UIWebViewBounce" value="false"/> <preference name="DisallowOverscroll" value="true"/> <preference name="SplashScreenDelay" value="2000"/> <preference name="FadeSplashScreenDuration" value="2000"/> <preference name="android-minSdkVersion" value="16"/> <preference name="BackupWebStorage" value="none"/> <preference name="SplashScreen" value="screen"/> <feature name="StatusBar"> <param name="ios-package" value="CDVStatusBar" onload="true"/> </feature> <platform name="ios"> <icon src="resources/ios/icon/icon.png" width="57" height="57"/> <icon src="resources/ios/icon/icon@2x.png" width="114" height="114"/> <icon src="resources/ios/icon/icon-40.png" width="40" height="40"/> <icon src="resources/ios/icon/icon-40@2x.png" width="80" height="80"/> <icon src="resources/ios/icon/icon-50.png" width="50" height="50"/> <icon src="resources/ios/icon/icon-50@2x.png" width="100" height="100"/> <icon src="resources/ios/icon/icon-60.png" width="60" height="60"/> <icon src="resources/ios/icon/icon-60@2x.png" width="120" height="120"/> <icon src="resources/ios/icon/icon-60@3x.png" width="180" height="180"/> <icon src="resources/ios/icon/icon-72.png" width="72" height="72"/> <icon src="resources/ios/icon/icon-72@2x.png" width="144" height="144"/> <icon src="resources/ios/icon/icon-76.png" width="76" height="76"/> <icon src="resources/ios/icon/icon-76@2x.png" width="152" height="152"/> <icon src="resources/ios/icon/icon-small.png" width="29" height="29"/> <icon src="resources/ios/icon/icon-small@2x.png" width="58" height="58"/> <icon src="resources/ios/icon/icon-small@3x.png" width="87" height="87"/> <splash src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" height="1136"/> <splash src="resources/ios/splash/Default-667h.png" width="750" height="1334"/> <splash src="resources/ios/splash/Default-736h.png" width="1242" height="2208"/> <splash src="resources/ios/splash/Default-Landscape-736h.png" width="2208" height="1242"/> <splash src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" height="1536"/> <splash src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" height="768"/> <splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" height="2048"/> <splash src="resources/ios/splash/Default-Portrait~ipad.png" width="768" height="1024"/> <splash src="resources/ios/splash/Default@2x~iphone.png" width="640" height="960"/> <splash src="resources/ios/splash/Default~iphone.png" width="320" height="480"/> </platform> <platform name="android"> <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/> <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/> <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/> <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/> <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/> <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/> <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/> <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/> <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/> <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/> <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/> <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/> <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/> <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/> <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/> <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/> <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/> </platform> <icon src="resources/android/icon/drawable-xhdpi-icon.png"/></widget>