mirror of
https://github.com/wangjunget/cordova-plugin-statusbar-height.git
synced 2026-04-22 00:00:03 +08:00
19 lines
532 B
JavaScript
19 lines
532 B
JavaScript
var exec = require('cordova/exec');
|
|
|
|
// 对外开放接, 回调函数接收状态栏高度值, 设备独立像素值
|
|
exports.getValue = function(success, error) {
|
|
// android px to pd
|
|
// android 返回px值
|
|
// ios 返回pt值
|
|
function pxToPd(value) {
|
|
var pdr = window.devicePixelRatio;
|
|
var pd = value / pdr;
|
|
if (cordova.platformId == 'android') {
|
|
success(pd)
|
|
} else {
|
|
success(value)
|
|
}
|
|
}
|
|
exec(pxToPd, error, 'StatusBarHeight', 'getValue', []);
|
|
}
|