diff --git a/src/Core/src/Platform/iOS/CheckBoxExtensions.cs b/src/Core/src/Platform/iOS/CheckBoxExtensions.cs index 03b64104326a..300fecc30f04 100644 --- a/src/Core/src/Platform/iOS/CheckBoxExtensions.cs +++ b/src/Core/src/Platform/iOS/CheckBoxExtensions.cs @@ -16,6 +16,11 @@ public static void UpdateForeground(this MauiCheckBox platformCheckBox, ICheckBo { platformCheckBox.CheckBoxTintColor = solid.Color; } + else if (check.Foreground is null) + { + // Color was cleared; reset to null so the view inherits the default tint color + platformCheckBox.CheckBoxTintColor = null; + } } } } \ No newline at end of file diff --git a/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.iOS.cs b/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.iOS.cs index be4b94d70cb0..b872e8ac4be0 100644 --- a/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.iOS.cs +++ b/src/Core/tests/DeviceTests/Handlers/CheckBox/CheckBoxHandlerTests.iOS.cs @@ -64,5 +64,31 @@ async Task ValidateColor(ICheckBox checkBoxStub, Color color, Action action = nu }); Assert.Equal(expected, color); } + + [Fact(DisplayName = "Foreground Resets to Default When Set to Null")] + public async Task ForegroundResetsToDefaultWhenSetToNull() + { + var checkBoxStub = new CheckBoxStub + { + Foreground = new SolidPaint(Colors.Red), + IsChecked = true + }; + + await InvokeOnMainThreadAsync(() => + { + var handler = CreateHandler(checkBoxStub); + var native = GetNativeCheckBox(handler); + + // Confirm that the red tint was applied initially + Assert.NotNull(native.CheckBoxTintColor); + + // Simulate a dynamic Color = null (Foreground reset to default) + checkBoxStub.Foreground = null; + handler.UpdateValue(nameof(ICheckBox.Foreground)); + + // After reset, the native tint must be null so iOS reverts to its inherited default + Assert.Null(native.CheckBoxTintColor); + }); + } } } \ No newline at end of file