diff --git a/src/Core/src/Platform/iOS/SafeAreaPadding.cs b/src/Core/src/Platform/iOS/SafeAreaPadding.cs index 6362ff875cb8..9c2c8aae338b 100644 --- a/src/Core/src/Platform/iOS/SafeAreaPadding.cs +++ b/src/Core/src/Platform/iOS/SafeAreaPadding.cs @@ -1,5 +1,6 @@ using CoreGraphics; using UIKit; +using System; namespace Microsoft.Maui.Platform; @@ -28,6 +29,18 @@ public CGRect InsetRect(CGRect bounds) internal static class SafeAreaInsetsExtensions { - public static SafeAreaPadding ToSafeAreaInsets(this UIEdgeInsets insets) => - new(insets.Left, insets.Right, insets.Top, insets.Bottom); + public static SafeAreaPadding ToSafeAreaInsets(this UIEdgeInsets insets) + { + // Filters out negligible floating-point values from UIKit that may cause layout issues (e.g., 3.5527136788005009e-15). + const double tolerance = 1e-14; + + static double ApplyTolerance(double value) => Math.Abs(value) < tolerance ? 0 : value; + + return new( + ApplyTolerance(insets.Left), + ApplyTolerance(insets.Right), + ApplyTolerance(insets.Top), + ApplyTolerance(insets.Bottom) + ); + } } \ No newline at end of file