From 14d26338b96f26727fa2ea06d74416aa54d454c3 Mon Sep 17 00:00:00 2001 From: Felix Mau Date: Mon, 10 May 2021 20:00:33 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20::=20Fix=20notch=20mask=20accide?= =?UTF-8?q?ntally=20applied=20to=20iPads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Classes/NotchGradientLoadingBarController.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift b/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift index c6bfae0..d4cec6c 100644 --- a/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift +++ b/GradientLoadingBar/Classes/NotchGradientLoadingBarController.swift @@ -39,7 +39,12 @@ open class NotchGradientLoadingBarController: GradientLoadingBarController { // The `safeAreaInsets.top` always includes the status-bar and therefore will always be greater "0". // As a workaround we check the bottom inset. let hasNotch = superview.safeAreaInsets.bottom > 0 - guard hasNotch else { + + // The iPad also has a bottom inset, in order to avoid the home indicator. (https://developer.apple.com/forums/thread/110724) + // As a workaround we explicitly make sure to have a phone device. + let isIPhone = UIDevice.current.userInterfaceIdiom == .phone + + guard hasNotch, isIPhone else { // No special masking required for non safe area devices. super.setupConstraints(superview: superview) return