[iOS] fix for SearchBar background color (#4229)

* iOS fix for SearchBar background color

* Update Xamarin.Forms.Controls.Issues.Shared.projitems

* Fix Merge Issues
- fixes #4194
This commit is contained in:
Andrei Nitescu 2018-11-13 20:00:39 +02:00 коммит произвёл Shane Neuville
Родитель 63e290a899
Коммит 3ad537c6b1
4 изменённых файлов: 52 добавлений и 3 удалений

Просмотреть файл

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Controls.Issues.Issue4194">
<StackLayout>
<Label Text="On iOS, after clicking the button, the second SearchBar should appear having same color as the first SearchBar, it should not be dark green " />
<SearchBar Text="Visible"
BackgroundColor="Lime" />
<SearchBar x:Name="SearchBar1"
IsVisible="false"
BackgroundColor="Lime" />
<Button Text="Show"
Clicked="Handle_Clicked"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage>

Просмотреть файл

@ -0,0 +1,25 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 4194, "[iOS] SearchBar changes color if initial state is invisible", PlatformAffected.iOS)]
public partial class Issue4194 : ContentPage
{
public Issue4194()
{
#if APP
InitializeComponent();
#endif
}
void Handle_Clicked(object sender, System.EventArgs e)
{
#if APP
SearchBar1.IsVisible = true;
#endif
}
}
}

Просмотреть файл

@ -405,6 +405,10 @@
<DependentUpon>Issue3979.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue4194.xaml.cs">
<DependentUpon>Issue4194.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Issue4136.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue4262.cs" />
<Compile Include="$(MSBuildThisFileDirectory)LegacyComponents\NonAppCompatSwitch.cs" />
@ -1021,6 +1025,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Controls\" />
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue2858.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
@ -1045,6 +1050,9 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Controls\" />
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue4194.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>

Просмотреть файл

@ -120,8 +120,7 @@ namespace Xamarin.Forms.Platform.iOS
Control.BarTintColor = color.ToUIColor(_defaultTintColor);
if (color.A < 1)
Control.SetBackgroundImage(new UIImage(), UIBarPosition.Any, UIBarMetrics.Default);
Control.SetBackgroundImage(new UIImage(), UIBarPosition.Any, UIBarMetrics.Default);
// updating BarTintColor resets the button color so we need to update the button color again
UpdateCancelButton();