【问题标题】:Ionic - Status Bar height离子 - 状态栏高度
【发布时间】:2023-04-24 11:48:01
【问题描述】:

离子有没有办法以 px 获得状态栏的高度? 我尝试使用screen.height - this.platform.height(),但它也为我提供了某些手机中 android 软底栏的高度。

【问题讨论】:

    标签: html css angular ionic-framework capacitor


    【解决方案1】:

    您可以尝试以下解决方案:

    var initialHeight = document.documentElement.clientHeight;
    window.addEventListener('resize', resizeFunction);
    function resizeFunction() {
        console.log('STATUS BAR HEIGHT', document.documentElement.clientHeight - initialHeight);
        window.removeEventListener('resize', resizeFunction);
    }
    StatusBar.overlaysWebView(true);
    

    参考:https://github.com/apache/cordova-plugin-statusbar/issues/112#issuecomment-825044394

    【讨论】: