From 12db027a80086b91da10cc7f3ca132fc09b633fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Sat, 27 Dec 2025 10:28:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0iOS=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用safeArea计算iPhone刘海边距 - 保留百分比作为安卓备用方案 --- pages/index/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index b6eaa56..492f69a 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -150,10 +150,18 @@ Page({ const systemInfo = wx.getSystemInfoSync(); const screenHeight = systemInfo.screenHeight * 2; + const safeArea = systemInfo.safeArea; const btnHeight = 90; - const minTop = screenHeight * 0.2; - const maxTop = screenHeight * 0.75; + let minTop, maxTop; + + if (safeArea && safeArea.top > 20) { + minTop = safeArea.top * 2 + 20; + maxTop = safeArea.bottom * 2 - btnHeight - 20; + } else { + minTop = screenHeight * 0.2; + maxTop = screenHeight * 0.6; + } if (newTop < minTop) { newTop = minTop;