cordova-plugin-splashscreen-啟動(dòng)頁

node 10.15.0
ionic 4.12.0
cordova 9.0
# platforms
cordova-android:8.0.0
cordova-ios: 5.0.0

安裝

ionic cordova plugin add cordova-plugin-splashscreen
npm install @ionic-native/splash-screen

配置

config.xml

屬性配置

// 拉伸
<preference name="SplashMaintainAspectRatio" value="true" />
// 淡入效果
<preference name="FadeSplashScreen" value="true" />
// 淡入延時(shí)
<preference name="FadeSplashScreenDuration" value="300" />
// 是否僅首次顯示
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
// 啟動(dòng)頁延時(shí)
<preference name="SplashScreenDelay" value="20000" />
// 自動(dòng)隱藏 默認(rèn)true
<preference name="AutoHideSplashScreen" value="false" />

資源配置

可根據(jù)自身情況選擇相應(yīng)的資源

<platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
</platform>
<platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
</platform>

使用

app.module.ts

import {SplashScreen} from '@ionic-native/splash-screen/ngx';
providers: [
  SplashScreen,
]

app.conponent.ts

import {SplashScreen} from '@ionic-native/splash-screen/ngx';
initializeApp() {
    this.platform.ready().then(() => {
      this.initSplashScreen();
    });
  }
// 淡入效果
initSplashScreen() {
    setTimeout(() => {
      this.splashScreen.hide();
    }, 300);
}

注意事項(xiàng):

  1. 必須在AppModule中聲明。

下一篇將介紹狀態(tài)欄插件:cordova-plugin-statusbar

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Plugin.xml plugin.xml文件定義了你的插件所需的結(jié)構(gòu)和設(shè)置。它有幾個(gè)元素來提供有關(guān)你的插件的詳細(xì)...
    葛高召閱讀 1,295評(píng)論 0 1
  • cordova基于HTML、CSS和JavaScript的,用于創(chuàng)建跨平臺(tái)移動(dòng)應(yīng)用程序的快速開發(fā)平臺(tái)。能夠利用iP...
    sunsboyxu閱讀 2,738評(píng)論 0 6
  • 導(dǎo)語 Apache Cordova是一個(gè)開源的移動(dòng)開發(fā)框架。允許你用標(biāo)準(zhǔn)的web技術(shù)-HTML5,CSS3和Jav...
    ApolloGuibo閱讀 4,548評(píng)論 2 9
  • 銜著窗外轟轟烈烈大雨聲轉(zhuǎn)醒的喜,一盆一盆的花草也全搬去了窗臺(tái)淋雨——啊啊誤會(huì),貓你怕水不要跟去,一起聽雨很好——人...
    郁致閱讀 305評(píng)論 0 1
  • 看完《釜山行》之后,有成功燃起了自己對(duì)韓國電影的向往,于是上網(wǎng)搜到了《隧道》這部電影。 隧道主要講述了男主在回...
    yyszl閱讀 17,021評(píng)論 0 0

友情鏈接更多精彩內(nèi)容