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 8826058cee0f..025ae0e77993 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/iOS/ShellPageRendererTracker.cs @@ -7,6 +7,7 @@ using System.Windows.Input; using CoreGraphics; using Foundation; +using Microsoft.Maui.Graphics; using Microsoft.Maui.Graphics.Platform; using UIKit; using static Microsoft.Maui.Controls.Compatibility.Platform.iOS.AccessibilityExtensions; @@ -498,13 +499,13 @@ void UpdateLeftToolbarItems() UIImage? icon = null; + var foregroundColor = _context?.Shell.CurrentPage?.GetValue(Shell.ForegroundColorProperty) as Color ?? + _context?.Shell.GetValue(Shell.ForegroundColorProperty) as Color; + if (image is not null) { icon = result?.Value; - var foregroundColor = _context?.Shell.CurrentPage?.GetValue(Shell.ForegroundColorProperty) ?? - _context?.Shell.GetValue(Shell.ForegroundColorProperty); - if (foregroundColor is null) { icon = icon?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); @@ -542,6 +543,16 @@ void UpdateLeftToolbarItems() { NavigationItem.LeftBarButtonItem = new UIBarButtonItem(icon, UIBarButtonItemStyle.Plain, (s, e) => LeftBarButtonItemHandler(ViewController, IsRootPage)) { Enabled = enabled }; + + // For iOS 26+, explicitly set the tint color on the bar button item + // because the navigation bar's tint color is not automatically inherited + if (OperatingSystem.IsIOSVersionAtLeast(26) || OperatingSystem.IsMacCatalystVersionAtLeast(26)) + { + if (foregroundColor is not null) + { + NavigationItem.LeftBarButtonItem.TintColor = foregroundColor.ToPlatform(); + } + } } else { diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ShellFlyoutIconShouldNotBeBlack.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ShellFlyoutIconShouldNotBeBlack.png new file mode 100644 index 000000000000..faf8fd4ddeb2 Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/ShellFlyoutIconShouldNotBeBlack.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue32867.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue32867.cs new file mode 100644 index 000000000000..b175d822fc48 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue32867.cs @@ -0,0 +1,42 @@ +namespace Maui.Controls.Sample.Issues; + +[Issue(IssueTracker.Github, 32867, "Shell Flyout Icon is always black", PlatformAffected.iOS)] +public class Issue32867 : Shell +{ + public Issue32867() + { + // Create a simple ShellContent with a content page + var shellContent = new ShellContent + { + Title = "Home", + + Content = new Issue32867Page() + }; + FlyoutBehavior = FlyoutBehavior.Flyout; + FlyoutIcon = "shopping_cart.png"; + Items.Add(shellContent); + + // Set Shell ForegroundColor (affects FlyoutIcon tint) + Shell.SetForegroundColor(this, Colors.Red); + } +} +public class Issue32867Page : ContentPage +{ + public Issue32867Page() + { + Content = new VerticalStackLayout + { + Padding = 20, + Spacing = 10, + Children = + { + new Label + { + Text = "The test passes if the Flyout icon appears in red (not black).", + AutomationId = "Issue32867Label" + }, + + } + }; + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ShellFlyoutIconShouldNotBeBlack.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ShellFlyoutIconShouldNotBeBlack.png new file mode 100644 index 000000000000..ae12b0e9e83c Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ShellFlyoutIconShouldNotBeBlack.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32867.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32867.cs new file mode 100644 index 000000000000..9c793a104ca8 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue32867.cs @@ -0,0 +1,22 @@ +#if TEST_FAILS_ON_WINDOWS // https://github.com/dotnet/maui/issues/26148 +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue32867 : _IssuesUITest +{ + public Issue32867(TestDevice testDevice) : base(testDevice) + { + } + public override string Issue => "Shell Flyout Icon is always black"; + + [Test] + [Category(UITestCategories.Shell)] + public void ShellFlyoutIconShouldNotBeBlack() + { + App.WaitForElement("Issue32867Label"); + VerifyScreenshot(); + } +} +#endif \ No newline at end of file diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ShellFlyoutIconShouldNotBeBlack.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ShellFlyoutIconShouldNotBeBlack.png new file mode 100644 index 000000000000..ec988a593add Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ShellFlyoutIconShouldNotBeBlack.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ShellFlyoutIconShouldNotBeBlack.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ShellFlyoutIconShouldNotBeBlack.png new file mode 100644 index 000000000000..2441dce42147 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ShellFlyoutIconShouldNotBeBlack.png differ