When I upgraded an app from .net maui 9.0.81 to 10.0.70, my SearchBar control did not show the correct background color and emitted a shadow.
I did some extensive research into this issue and tried a lot of the suggested workarounds. Nothing fully worked.
The problem also shows up in a .net maui app project generated by Visual Studio 2026, with the sample code included option. On the MainPage I eliminated all the rows from the main grid and added a single row with a SearchBar. I also made the page background white (in Colors.xaml).
Resulting MainPage.xaml subset:
<ScrollView>
<Grid Padding="{StaticResource LayoutPadding}" RowSpacing="{StaticResource LayoutSpacing}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" ColumnDefinitions="*,*">
<SearchBar Grid.Column="0"/>
<BoxView Grid.Column="1" Color="Red" />
</Grid>
</Grid>
</ScrollView>
Resulting MauiProgram.cs subset:
Microsoft.Maui.Handlers.SearchBarHandler.Mapper.AppendToMapping("CustomSearchBar", (handler, view) =>
{
#if IOS
handler.PlatformView.SearchBarStyle = UIKit.UISearchBarStyle.Minimal;
handler.PlatformView.BackgroundColor = UIKit.UIColor.Red;
handler.PlatformView.BarTintColor = UIKit.UIColor.Red;
handler.PlatformView.Translucent = false;
handler.PlatformView.Opaque = true;
handler.PlatformView.Layer.BorderWidth = 0;
handler.PlatformView.Layer.ShadowOpacity = 0;
handler.PlatformView.BackgroundImage = new UIKit.UIImage();
#endif
});
Partial Main page snapshot when running app on an iPhone 15, iOS 26.5:

Notice that the background of the search bar on the left is not the same color as on the right, whereas they are both specified as "Red".
Also, if you sample the colors you will see that there is a light gray shadow around the search bar (except on the right) that gradually filters into the white background color.
What is the proper way to eliminate the "darkening" of the background color on the search bar?
If the shadow cannot be eliminated, that is OK. I'm mainly concerned about the search bar background color.
Thank you.