IONIC4 沉浸式导航栏

IONIC android设置沉浸式导航栏,IOS 无需设置,自动实现沉浸式。

效果图展示:

D777A3167C57CD37E6DA007CCD4735AC.jpg
6EB6C8A3BA7D49EF80BDC20F09CFA7AF.jpg
27C69602AC7324A36E72551FF69863CE.jpg

1 : 引入该版本插件 "@ionic-native/splash-screen": "^5.10.0" , "@ionic-native/status-bar": "^5.11.0",并 修改android 源码 替换为

splashscreen.java 源码:

/*
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
     regarding copyright ownership.  The ASF licenses this file
     to you under the Apache License, Version 2.0 (the
     "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
*/

package org.apache.cordova.splashscreen;

import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AlphaAnimation;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.json.JSONArray;
import org.json.JSONException;

public class SplashScreen extends CordovaPlugin {
  private static final String LOG_TAG = "SplashScreen";
  // Cordova 3.x.x has a copy of this plugin bundled with it (SplashScreenInternal.java).
  // Enable functionality only if running on 4.x.x.
  private static final boolean HAS_BUILT_IN_SPLASH_SCREEN = Integer.valueOf(CordovaWebView.CORDOVA_VERSION.split("\\.")[0]) < 4;
  private static final int DEFAULT_SPLASHSCREEN_DURATION = 3000;
  private static final int DEFAULT_FADE_DURATION = 500;
  private static Dialog splashDialog;
  private static ProgressDialog spinnerDialog;
  private static boolean firstShow = true;
  private static boolean lastHideAfterDelay; // https://issues.apache.org/jira/browse/CB-9094

  /**
   * Displays the splash drawable.
   */
  private ImageView splashImageView;

  /**
   * Remember last device orientation to detect orientation changes.
   */
  private int orientation;

  // Helper to be compile-time compatible with both Cordova 3.x and 4.x.
  private View getView() {
      try {
          return (View)webView.getClass().getMethod("getView").invoke(webView);
      } catch (Exception e) {
          return (View)webView;
      }
  }

  private int getSplashId() {
      int drawableId = 0;
      String splashResource = preferences.getString("SplashScreen", "screen");
      if (splashResource != null) {
          drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getClass().getPackage().getName());
          if (drawableId == 0) {
              drawableId = cordova.getActivity().getResources().getIdentifier(splashResource, "drawable", cordova.getActivity().getPackageName());
          }
      }
      return drawableId;
  }

  @Override
  protected void pluginInitialize() {
      if (HAS_BUILT_IN_SPLASH_SCREEN) {
          return;
      }
      // Make WebView invisible while loading URL
      // CB-11326 Ensure we're calling this on UI thread
      cordova.getActivity().runOnUiThread(new Runnable() {
          @Override
          public void run() {
              getView().setVisibility(View.INVISIBLE);
          }
      });
      int drawableId = getSplashId();

      // Save initial orientation.
      orientation = cordova.getActivity().getResources().getConfiguration().orientation;

      if (firstShow) {
          boolean autoHide = preferences.getBoolean("AutoHideSplashScreen", true);
          showSplashScreen(autoHide);
      }

      if (preferences.getBoolean("SplashShowOnlyFirstTime", true)) {
          firstShow = false;
      }
  }

  /**
   * Shorter way to check value of "SplashMaintainAspectRatio" preference.
   */
  private boolean isMaintainAspectRatio () {
      return preferences.getBoolean("SplashMaintainAspectRatio", false);
  }

  private int getFadeDuration () {
      int fadeSplashScreenDuration = preferences.getBoolean("FadeSplashScreen", true) ?
          preferences.getInteger("FadeSplashScreenDuration", DEFAULT_FADE_DURATION) : 0;

      if (fadeSplashScreenDuration < 30) {
          // [CB-9750] This value used to be in decimal seconds, so we will assume that if someone specifies 10
          // they mean 10 seconds, and not the meaningless 10ms
          fadeSplashScreenDuration *= 1000;
      }

      return fadeSplashScreenDuration;
  }

  @Override
  public void onPause(boolean multitasking) {
      if (HAS_BUILT_IN_SPLASH_SCREEN) {
          return;
      }
      // hide the splash screen to avoid leaking a window
      this.removeSplashScreen(true);
  }

  @Override
  public void onDestroy() {
      if (HAS_BUILT_IN_SPLASH_SCREEN) {
          return;
      }
      // hide the splash screen to avoid leaking a window
      this.removeSplashScreen(true);
      // If we set this to true onDestroy, we lose track when we go from page to page!
      //firstShow = true;
  }

  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
      if (action.equals("hide")) {
          cordova.getActivity().runOnUiThread(new Runnable() {
              public void run() {
                  webView.postMessage("splashscreen", "hide");
              }
          });
      } else if (action.equals("show")) {
          cordova.getActivity().runOnUiThread(new Runnable() {
              public void run() {
                  webView.postMessage("splashscreen", "show");
              }
          });
      } else {
          return false;
      }

      callbackContext.success();
      return true;
  }

  @Override
  public Object onMessage(String id, Object data) {
      if (HAS_BUILT_IN_SPLASH_SCREEN) {
          return null;
      }
      if ("splashscreen".equals(id)) {
          if ("hide".equals(data.toString())) {
              this.removeSplashScreen(false);
          } else {
              this.showSplashScreen(false);
          }
      } else if ("spinner".equals(id)) {
          if ("stop".equals(data.toString())) {
              getView().setVisibility(View.VISIBLE);
          }
      } else if ("onReceivedError".equals(id)) {
          this.spinnerStop();
      }
      return null;
  }

  // Don't add @Override so that plugin still compiles on 3.x.x for a while
  public void onConfigurationChanged(Configuration newConfig) {
      if (newConfig.orientation != orientation) {
          orientation = newConfig.orientation;

          // Splash drawable may change with orientation, so reload it.
          if (splashImageView != null) {
              int drawableId = getSplashId();
              if (drawableId != 0) {
                  splashImageView.setImageDrawable(cordova.getActivity().getResources().getDrawable(drawableId));
              }
          }
      }
  }

  private void removeSplashScreen(final boolean forceHideImmediately) {
      cordova.getActivity().runOnUiThread(new Runnable() {
          public void run() {
              if (splashDialog != null && splashDialog.isShowing()) {
                  final int fadeSplashScreenDuration = getFadeDuration();
                  // CB-10692 If the plugin is being paused/destroyed, skip the fading and hide it immediately
                  if (fadeSplashScreenDuration > 0 && forceHideImmediately == false) {
                      AlphaAnimation fadeOut = new AlphaAnimation(1, 0);
                      fadeOut.setInterpolator(new DecelerateInterpolator());
                      fadeOut.setDuration(fadeSplashScreenDuration);

                      splashImageView.setAnimation(fadeOut);
                      splashImageView.startAnimation(fadeOut);

                      fadeOut.setAnimationListener(new Animation.AnimationListener() {
                          @Override
                          public void onAnimationStart(Animation animation) {
                              spinnerStop();
                          }

                          @Override
                          public void onAnimationEnd(Animation animation) {
                              if (splashDialog != null && splashDialog.isShowing()) {
                                  splashDialog.dismiss();
                                  splashDialog = null;
                                  splashImageView = null;
                              }
                          }

                          @Override
                          public void onAnimationRepeat(Animation animation) {
                          }
                      });
                  } else {
                      spinnerStop();
                      splashDialog.dismiss();
                      splashDialog = null;
                      splashImageView = null;
                  }
              }
          }
      });
  }

  /**
   * Shows the splash screen over the full Activity
   */
  @SuppressWarnings("deprecation")
  private void showSplashScreen(final boolean hideAfterDelay) {
      final int splashscreenTime = preferences.getInteger("SplashScreenDelay", DEFAULT_SPLASHSCREEN_DURATION);
      final int drawableId = getSplashId();

      final int fadeSplashScreenDuration = getFadeDuration();
      final int effectiveSplashDuration = Math.max(0, splashscreenTime - fadeSplashScreenDuration);

      lastHideAfterDelay = hideAfterDelay;

      // Prevent to show the splash dialog if the activity is in the process of finishing
      if (cordova.getActivity().isFinishing()) {
          return;
      }
      // If the splash dialog is showing don't try to show it again
      if (splashDialog != null && splashDialog.isShowing()) {
          return;
      }
      if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) {
          return;
      }

      cordova.getActivity().runOnUiThread(new Runnable() {
          public void run() {
              // Get reference to display
              Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
              Context context = webView.getContext();

              // Use an ImageView to render the image because of its flexible scaling options.
              splashImageView = new ImageView(context);
              splashImageView.setImageResource(drawableId);
              LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
              splashImageView.setLayoutParams(layoutParams);

              splashImageView.setMinimumHeight(display.getHeight());
              splashImageView.setMinimumWidth(display.getWidth());

              // TODO: Use the background color of the webView's parent instead of using the preference.
              splashImageView.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK));

              if (isMaintainAspectRatio()) {
                  // CENTER_CROP scale mode is equivalent to CSS "background-size:cover"
                  splashImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
              }
              else {
                  // FIT_XY scales image non-uniformly to fit into image view.
                  splashImageView.setScaleType(ImageView.ScaleType.FIT_XY);
              }

              // Create and show the dialog
              splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
              // check to see if the splash screen should be full screen
              if ((cordova.getActivity().getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                      == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                  splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                          WindowManager.LayoutParams.FLAG_FULLSCREEN);
              }
              splashDialog.setContentView(splashImageView);
              splashDialog.setCancelable(false);
              splashDialog.show();

              if (preferences.getBoolean("ShowSplashScreenSpinner", true)) {
                  spinnerStart();
              }

              // Set Runnable to remove splash screen just in case
              if (hideAfterDelay) {
                  final Handler handler = new Handler();
                  handler.postDelayed(new Runnable() {
                      public void run() {
                          if (lastHideAfterDelay) {
                              removeSplashScreen(false);
                          }
                      }
                  }, effectiveSplashDuration);
              }
          }
      });
  }

  // Show only spinner in the center of the screen
  private void spinnerStart() {
      cordova.getActivity().runOnUiThread(new Runnable() {
          public void run() {
              spinnerStop();

              spinnerDialog = new ProgressDialog(webView.getContext());
              spinnerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                  public void onCancel(DialogInterface dialog) {
                      spinnerDialog = null;
                  }
              });

              spinnerDialog.setCancelable(false);
              spinnerDialog.setIndeterminate(true);

              RelativeLayout centeredLayout = new RelativeLayout(cordova.getActivity());
              centeredLayout.setGravity(Gravity.CENTER);
              centeredLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

              ProgressBar progressBar = new ProgressBar(webView.getContext());
              RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
              progressBar.setLayoutParams(layoutParams);

              if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                  String colorName = preferences.getString("SplashScreenSpinnerColor", null);
                  if(colorName != null){
                      int[][] states = new int[][] {
                          new int[] { android.R.attr.state_enabled}, // enabled
                          new int[] {-android.R.attr.state_enabled}, // disabled
                          new int[] {-android.R.attr.state_checked}, // unchecked
                          new int[] { android.R.attr.state_pressed}  // pressed
                      };
                      int progressBarColor = Color.parseColor(colorName);
                      int[] colors = new int[] {
                          progressBarColor,
                          progressBarColor,
                          progressBarColor,
                          progressBarColor
                      };
                      ColorStateList colorStateList = new ColorStateList(states, colors);
                      progressBar.setIndeterminateTintList(colorStateList);
                  }
              }

              centeredLayout.addView(progressBar);

              spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
              spinnerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

              spinnerDialog.show();
              spinnerDialog.setContentView(centeredLayout);
          }
      });
  }

  private void spinnerStop() {
      cordova.getActivity().runOnUiThread(new Runnable() {
          public void run() {
              if (spinnerDialog != null && spinnerDialog.isShowing()) {
                  spinnerDialog.dismiss();
                  spinnerDialog = null;
              }
          }
      });
  }
}

statusbar.java 源码

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.cordova.statusbar;

import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaArgs;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.LOG;
import org.apache.cordova.PluginResult;
import org.json.JSONException;
import java.util.Arrays;

public class StatusBar extends CordovaPlugin {
  private static final String TAG = "StatusBar";

  /**
   * Sets the context of the Command. This can then be used to do things like
   * get file paths associated with the Activity.
   *
   * @param cordova The context of the main Activity.
   * @param webView The CordovaWebView Cordova is running in.
   */
  @Override
  public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
      LOG.v(TAG, "StatusBar: initialization");
      super.initialize(cordova, webView);

      this.cordova.getActivity().runOnUiThread(new Runnable() {
          @Override
          public void run() {
              // Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially
              // by the Cordova.
              Window window = cordova.getActivity().getWindow();
              window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

              // Read 'StatusBarBackgroundColor' from config.xml, default is #000000.
              setStatusBarBackgroundColor(preferences.getString("StatusBarBackgroundColor", "#000000"));

              // Read 'StatusBarStyle' from config.xml, default is 'lightcontent'.
              setStatusBarStyle(preferences.getString("StatusBarStyle", "lightcontent"));
          }

      });
  }

  /**
   * Executes the request and returns PluginResult.
   *
   * @param action            The action to execute.
   * @param args              JSONArry of arguments for the plugin.
   * @param callbackContext   The callback id used when calling back into JavaScript.
   * @return                  True if the action was valid, false otherwise.
   */
  @Override
  public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
      LOG.v(TAG, "Executing action: " + action);
      final Activity activity = this.cordova.getActivity();
      final Window window = activity.getWindow();

      if ("_ready".equals(action)) {
          boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
          callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
          return true;
      }

      if ("show".equals(action)) {
          this.cordova.getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  // SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
                  // use KitKat here to be aligned with "Fullscreen"  preference
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                      int uiOptions = window.getDecorView().getSystemUiVisibility();
                      uiOptions &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
                      uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;

                      window.getDecorView().setSystemUiVisibility(uiOptions);
                  }

                  // CB-11197 We still need to update LayoutParams to force status bar
                  // to be hidden when entering e.g. text fields
                  window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
              }
          });
          return true;
      }

      if ("hide".equals(action)) {
          this.cordova.getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  // SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
                  // use KitKat here to be aligned with "Fullscreen"  preference
                  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                      int uiOptions = window.getDecorView().getSystemUiVisibility()
                              | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                              | View.SYSTEM_UI_FLAG_FULLSCREEN;

                      window.getDecorView().setSystemUiVisibility(uiOptions);
                  }

                  // CB-11197 We still need to update LayoutParams to force status bar
                  // to be hidden when entering e.g. text fields
                  window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
              }
          });
          return true;
      }

      if ("backgroundColorByHexString".equals(action)) {
          this.cordova.getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  try {
                      setStatusBarBackgroundColor(args.getString(0));
                  } catch (JSONException ignore) {
                      LOG.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
                  }
              }
          });
          return true;
      }

      if ("overlaysWebView".equals(action)) {
          if (Build.VERSION.SDK_INT >= 21) {
              this.cordova.getActivity().runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                      try {
                          setStatusBarTransparent(args.getBoolean(0));
                      } catch (JSONException ignore) {
                          LOG.e(TAG, "Invalid boolean argument");
                      }
                  }
              });
              return true;
          }
          else return args.getBoolean(0) == false;
      }

      if ("styleDefault".equals(action)) {
          this.cordova.getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  setStatusBarStyle("default");
              }
          });
          return true;
      }

      if ("styleLightContent".equals(action)) {
          this.cordova.getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  setStatusBarStyle("lightcontent");
              }
          });
          return true;
      }

      if ("styleBlackTranslucent".equals(action)) {
          this.cordova.getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  setStatusBarStyle("blacktranslucent");
              }
          });
          return true;
      }

      if ("styleBlackOpaque".equals(action)) {
          this.cordova.getActivity().runOnUiThread(new Runnable() {
              @Override
              public void run() {
                  setStatusBarStyle("blackopaque");
              }
          });
          return true;
      }

      return false;
  }

  private void setStatusBarBackgroundColor(final String colorPref) {
      if (Build.VERSION.SDK_INT >= 21) {
          if (colorPref != null && !colorPref.isEmpty()) {
              final Window window = cordova.getActivity().getWindow();
              // Method and constants not available on all SDKs but we want to be able to compile this code with any SDK
              window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
              window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
              try {
                  // Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21
                  window.getClass().getMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref));
              } catch (IllegalArgumentException ignore) {
                  LOG.e(TAG, "Invalid hexString argument, use f.i. '#999999'");
              } catch (Exception ignore) {
                  // this should not happen, only in case Android removes this method in a version > 21
                  LOG.w(TAG, "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT);
              }
          }
      }
  }

  private void setStatusBarTransparent(final boolean transparent) {
      if (Build.VERSION.SDK_INT >= 21) {
          final Window window = cordova.getActivity().getWindow();
          if (transparent) {
              window.getDecorView().setSystemUiVisibility(
                      View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                              | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
              window.setStatusBarColor(Color.TRANSPARENT);
          }
          else {
              window.getDecorView().setSystemUiVisibility(
                      View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                              | View.SYSTEM_UI_FLAG_VISIBLE);
          }
      }
  }

  private void setStatusBarStyle(final String style) {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
          if (style != null && !style.isEmpty()) {
              View decorView = cordova.getActivity().getWindow().getDecorView();
              int uiOptions = decorView.getSystemUiVisibility();

              String[] darkContentStyles = {
                  "default",
              };

              String[] lightContentStyles = {
                  "lightcontent",
                  "blacktranslucent",
                  "blackopaque",
              };

              if (Arrays.asList(darkContentStyles).contains(style.toLowerCase())) {
                  decorView.setSystemUiVisibility(uiOptions | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                  return;
              }

              if (Arrays.asList(lightContentStyles).contains(style.toLowerCase())) {
                  decorView.setSystemUiVisibility(uiOptions & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
                  return;
              }

              LOG.e(TAG, "Invalid style, must be either 'default', 'lightcontent' or the deprecated 'blacktranslucent' and 'blackopaque'");
          }
      }
  }
}

2: 修改 app.component.ts

this.statusBar.overlaysWebView(true);

即可

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,525评论 6 507
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,203评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,862评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,728评论 1 294
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,743评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,590评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,330评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,244评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,693评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,885评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,001评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,723评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,343评论 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,919评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,042评论 1 270
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,191评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,955评论 2 355

推荐阅读更多精彩内容

  • 目录 如何实现? 集成DEMO 简短的分析 一个额外的小栗子 我想让状态栏变色怎么办? 为什么这么做? 总结 效果...
    jeneser阅读 15,762评论 17 23
  • 目录 如何实现? 集成DEMO 简短的分析 一个额外的小栗子 我想让状态栏变色怎么办? 为什么这么做? 总结 效果...
    luoluoangel阅读 230评论 0 0
  • 目录 如何实现? 集成DEMO 简短的分析 一个额外的小栗子 我想让状态栏变色怎么办? 为什么这么做? 总结 效果...
    luoluoangel阅读 158评论 0 0
  • 各种帮助类汇总:https://github.com/Blankj/AndroidUtilCode 常用的 ios...
    懦弱的me阅读 1,231评论 0 51
  • 自己总结的Android开源项目及库。 github排名https://github.com/trending,g...
    passiontim阅读 2,538评论 1 26