Skip to content
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

Merged
merged 4 commits into from Nov 13, 2018

Conversation

andreinitescu
Copy link
Contributor

@andreinitescu andreinitescu commented Oct 26, 2018

Description of Change

On iOS, if a SearchBar is created with IsVisible="false" and a BackgroundColor, after it's made later made visible by setting IsVisible to true, the background color is darkened.

What's interesting is that if the SearchBar is put right as a child of the Page, the issue doesn't appear. Issue only appears when SearchBar is inside a container like Grid or StackLayout

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 this

Issues Resolved

API Changes

None

Platforms Affected

  • iOS

Behavioral/Visual Changes

See description and screenshots

Before/After Screenshots

Before:
image

After:
image

Testing Procedure

I added a test page for this issue with instructions.

image

PR Checklist

  • Has automated tests
  • Rebased on top of the target branch at time of PR
  • Changes adhere to coding standard

@PureWeen
Copy link
Contributor

Can you rebase to fix conflict please?

@andreinitescu
Copy link
Contributor Author

@PureWeen Sure, done!

@samhouts samhouts added this to In Review in v3.6.0 Oct 29, 2018
@@ -120,8 +120,7 @@ protected override void SetBackgroundColor(Color color)

Control.BarTintColor = color.ToUIColor(_defaultTintColor);

if (color.A < 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@PureWeen PureWeen left a 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.

@rmarinho
Copy link
Member

rmarinho commented Nov 9, 2018

build

@PureWeen PureWeen moved this from In Review to In Progress in v3.6.0 Nov 9, 2018
@PureWeen PureWeen merged commit 3ad537c into xamarin:master Nov 13, 2018
v3.6.0 automation moved this from In Progress to Done Nov 13, 2018
@hartez hartez added the approved Has two approvals, no pending reviews, and no changes requested label Nov 14, 2018
@samhouts samhouts added this to the 4.0.0 milestone Dec 4, 2018
@samhouts samhouts removed this from Done in v3.6.0 Jan 3, 2019
@samhouts samhouts modified the milestones: 4.0.0, 3.5.0 Jan 10, 2019
@samhouts samhouts added this to Done in v3.5.0 Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Has two approvals, no pending reviews, and no changes requested hacktoberfest 🍻 p/iOS 🍎 t/bug 🐛
Projects
No open projects
v3.5.0
  
Done
Development

Successfully merging this pull request may close these issues.

SearchBar changes color if initial state is invisible
5 participants