diff --git a/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs index 5371d80e4c09..58903e2b42c7 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/NavigationPage/iOS/NavigationRenderer.cs @@ -977,16 +977,27 @@ internal static void SetFlyoutLeftBarButton(UIViewController containerController { var icon = result?.Value; var originalImageSize = icon?.Size ?? CGSize.Empty; - // Referred from the default hamburger size - var defaultIconHeight = 23f; - var defaultIconWidth = 23f; + + // The largest height you can use for navigation bar icons in iOS. + // Per Apple's Human Interface Guidelines, the navigation bar height is 44 points, + // so using the full height ensures maximum visual clarity and maintains consistency + // with iOS design standards. This allows icons to utilize the entire available + // vertical space within the navigation bar container. + var defaultIconHeight = 44f; var buffer = 0.1; + // We only check height because the navigation bar constrains vertical space (44pt height), + // but allows horizontal flexibility. Width can vary based on icon design and content, + // while height must fit within the fixed navigation bar bounds to avoid clipping. + // if the image is bigger than the default available size, resize it if (icon is not null) { - if (originalImageSize.Height - defaultIconHeight > buffer || originalImageSize.Width - defaultIconWidth > buffer) + if (originalImageSize.Height - defaultIconHeight > buffer) { - icon = icon.ResizeImageSource(defaultIconWidth, defaultIconHeight, originalImageSize); + if (FlyoutPage.Flyout.IconImageSource is not FontImageSource fontImageSource || !fontImageSource.IsSet(FontImageSource.SizeProperty)) + { + icon = icon.ResizeImageSource(originalImageSize.Width, defaultIconHeight, originalImageSize); + } } try { diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs index c6b16347e6af..43637b563307 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs @@ -465,15 +465,26 @@ void UpdateLeftToolbarItems() { icon = result?.Value; var originalImageSize = icon?.Size ?? CGSize.Empty; - // Referred from the default hamburger size - var defaultIconHeight = 23f; - var defaultIconWidth = 23f; + + // The largest height you can use for navigation bar icons in iOS. + // Per Apple's Human Interface Guidelines, the navigation bar height is 44 points, + // so using the full height ensures maximum visual clarity and maintains consistency + // with iOS design standards. This allows icons to utilize the entire available + // vertical space within the navigation bar container. + var defaultIconHeight = 44f; var buffer = 0.1; + // We only check height because the navigation bar constrains vertical space (44pt height), + // but allows horizontal flexibility. Width can vary based on icon design and content, + // while height must fit within the fixed navigation bar bounds to avoid clipping. + // if the image is bigger than the default available size, resize it - if (icon is not null && originalImageSize.Height - defaultIconHeight > buffer || originalImageSize.Width - defaultIconWidth > buffer) + if (icon is not null && originalImageSize.Height - defaultIconHeight > buffer) { - icon = icon.ResizeImageSource(defaultIconWidth, defaultIconHeight, originalImageSize); + if (image is not FontImageSource fontImageSource || !fontImageSource.IsSet(FontImageSource.SizeProperty)) + { + icon = icon.ResizeImageSource(originalImageSize.Width, defaultIconHeight, originalImageSize); + } } } else if (String.IsNullOrWhiteSpace(text) && IsRootPage && _flyoutBehavior == FlyoutBehavior.Flyout) diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/FlyoutIconShouldAutoscale.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/FlyoutIconShouldAutoscale.png index 73fe8cde6b9f..4161eb71251d 100644 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/FlyoutIconShouldAutoscale.png and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/FlyoutIconShouldAutoscale.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/FlyoutIconShouldAutoscale.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/FlyoutIconShouldAutoscale.png index 94efd683b2bf..2dbebcbcea20 100644 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/FlyoutIconShouldAutoscale.png and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/FlyoutIconShouldAutoscale.png differ