New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] fix for SearchBar background color #4229
Conversation
Can you rebase to fix conflict please? |
97d4ff6
to
b9a12db
Compare
@PureWeen Sure, done! |
@@ -120,8 +120,7 @@ protected override void SetBackgroundColor(Color color) | |||
|
|||
Control.BarTintColor = color.ToUIColor(_defaultTintColor); | |||
|
|||
if (color.A < 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rmarinho Do you remember why this if
statement was here? It came from https://github.com/xamarin/Duplo/pull/3265 and https://github.com/xamarin/Duplo/pull/3304 (fixes for https://bugzilla.xamarin.com/show_bug.cgi?id=31669).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't recall tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hartez My take on the logic for the if
is this: if there's any transparency set on the color, clear the background image so that the tint color actually uses that color with alpha, otherwise it won't work. I think the idea was that clearing the background image is not necessary otherwise, and just setting the BarTintColor
should work, but it looks like it doesn't always. Not sure if this helps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build error. Possibly from a bad merge?
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
Xamarin.Forms.Controls.Issues\Xamarin.Forms.Controls.Issues.Shared\Xamarin.Forms.Controls.Issues.Shared.projitems(1056,3): Error MSB4067: The element <Folder> beneath element <Project> is unrecognized.
build |
Description of Change
On iOS, if a
SearchBar
is created withIsVisible="false"
and aBackgroundColor
, after it's made later made visible by settingIsVisible
totrue
, the background color is darkened.What's interesting is that if the
SearchBar
is put right as a child of thePage
, the issue doesn't appear. Issue only appears whenSearchBar
is inside a container likeGrid
orStackLayout
This fix makes ensures the background image is always cleared so that the color set by BarTintColor is always reflected in the
SearchBar
look. Per my investigation, without always setting the background image, it looks like there are some issues sometimes with UISearchBar. Not sure if it's completely related but I stumbled on thisIssues Resolved
API Changes
None
Platforms Affected
Behavioral/Visual Changes
See description and screenshots
Before/After Screenshots
Before:
After:
Testing Procedure
I added a test page for this issue with instructions.
PR Checklist