GIF File in splash screen Ionic

℡╲_俬逩灬. 提交于 2019-12-03 16:32:19

问题


I am developing a hybrid application with ionic-framework and Cordova plugins. They asked me the splash screen on both operating systems (iOS and Android) has a small animation. I imagine a GIF but not if you can load a GIF as splash screen. Or if there is a plugin for this.


回答1:


You can do it this way without using plugins. More information is available here.

HTML

 <body>
       <div id="custom-overlay"><img src="http://cdn.osxdaily.com/wp-content/uploads/2013/07/dancing-banana.gif"></div> 
      <!-- Here comes rest of the content -->
    </body>

www/css/style.css

#custom-overlay {
  display: flex;
  flex-direction: column;
  justify-content: center;  
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  background-color: #fe201f;
}

#custom-overlay img {
  display: block;
  margin: 0 auto;
  width: 60%;
  height: auto;
}

www/js/app.js

 .run(function($ionicPlatform, $state, $cordovaSplashscreen) {
      $ionicPlatform.ready(function() {
      if(navigator.splashscreen) {
        $cordovaSplashscreen.hide();
      } 
      });
    });

 .controller('ListCtrl', function($scope) {
  $scope.$on('$ionicView.afterEnter', function(){
    setTimeout(function(){
      document.getElementById("custom-overlay").style.display = "none";      
    }, 3000);
  });  
});


来源:https://stackoverflow.com/questions/31349581/gif-file-in-splash-screen-ionic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!