dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.27k stars 1.76k forks source link

[iOS][maccatalyst] SearchBar BackgroundColor is black when set to transparent #11677

Open matt-goldman opened 2 years ago

matt-goldman commented 2 years ago

Description

On iOS and MacCatalyst, if you set the BackgroundColor of a SearchBar to Transparent, the background goes black. This only seems to occur if you change it or set it explicitly and not with the default value.

Does not occur on Windows or Android.

Steps to Reproduce

  1. Create a new .NET MAUI app
  2. Add a SearchBar
  3. Explicitly set the BackgroundColor property of the SearchBar to Transparent, or change it to Transparent at runtime
  4. Observe the black background

Link to public reproduction project repository

https://github.com/matt-goldman/MauiTransparentBackgroundBug

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS, macOS

Affected platform versions

macOS 13.0.1, iOS 14 (not tested on other versions)

Did you find any workaround?

No response

Relevant log output

No response

nebula2 commented 1 year ago

maybe this is what you're looking for:

https://learn.microsoft.com/en-us/dotnet/maui/ios/platform-specifics/searchbar-style?view=net-maui-7.0

matt-goldman commented 1 year ago

Thanks, that helped. I wonder if that should be the default? Would make it consistent with the other platforms.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Adelzu commented 1 year ago

Hit same issue. Workaround, Change Styles.xaml

<Style TargetType="SearchBar">
        <Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource LightBackground}, Dark={StaticResource DarkBackground}}" />
</Style>
alexsmi-noveo commented 7 months ago

The same issue is also for me. SearchBar under ios (net 7.0, net 8.0.21, ios 17.2, ios 16.4) ignores UISearchBarStyle and colors from Styles.xaml and direct property assign. ios SearchBarStyle change explicitly on runtime (from Minimum to Default and back to Minimum) makes effect only in that case.

markuspalme commented 3 weeks ago

Can confirm this issue - a SearchBar without any colors specified renders with a black background in iOS (no dark mode set):

<SearchBar  Text="{Binding SearchText}" Placeholder="Suche" SearchCommand="{Binding SearchCommand}" />

Image

Setting ios:SearchBar.SearchBarStyle="Minimal" helps.