From 5a4bb7c38cc694a312135e44022d5a4c8dc79d1c Mon Sep 17 00:00:00 2001 From: Dimitris-Rafail Katsampas Date: Fri, 24 Nov 2023 20:04:06 +0200 Subject: [PATCH] fix(ios): shadow does not consider z-index (#10433) --- packages/core/ui/core/view/index.ios.ts | 8 +++++++- packages/core/ui/styling/background.ios.ts | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index 0df1791ec..c18d5189e 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -864,7 +864,13 @@ export class View extends ViewCommon implements ViewDefinition { return 0; } [zIndexProperty.setNative](value: number) { - this.nativeViewProtected.layer.zPosition = value; + const nativeView: NativeScriptUIView = this.nativeViewProtected; + + nativeView.layer.zPosition = value; + // Apply z-index to shadows as well + if (nativeView.outerShadowContainerLayer) { + nativeView.outerShadowContainerLayer.zPosition = value; + } } [backgroundInternalProperty.getDefault](): UIColor { diff --git a/packages/core/ui/styling/background.ios.ts b/packages/core/ui/styling/background.ios.ts index bcb14f8c3..f27ef5f73 100644 --- a/packages/core/ui/styling/background.ios.ts +++ b/packages/core/ui/styling/background.ios.ts @@ -143,7 +143,7 @@ export namespace ios { } if (!needsMask) { - clearLayerMask(nativeView, background); + clearLayerMask(nativeView); } // Clear box shadow if it's no longer needed @@ -345,7 +345,7 @@ function maskLayerIfNeeded(nativeView: NativeScriptUIView, background: Backgroun } } -function clearLayerMask(nativeView: NativeScriptUIView, background: BackgroundDefinition) { +function clearLayerMask(nativeView: NativeScriptUIView) { if (nativeView.outerShadowContainerLayer) { nativeView.outerShadowContainerLayer.mask = null; } @@ -1127,6 +1127,7 @@ function drawBoxShadow(view: View): void { outerShadowContainerLayer.bounds = bounds; outerShadowContainerLayer.anchorPoint = layer.anchorPoint; outerShadowContainerLayer.position = nativeView.center; + outerShadowContainerLayer.zPosition = layer.zPosition; // Inherit view visibility values outerShadowContainerLayer.opacity = layer.opacity;