diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45284.xaml b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45284.xaml new file mode 100644 index 00000000000..7d698656202 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45284.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45284.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45284.xaml.cs new file mode 100644 index 00000000000..e3f0a207abc --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45284.xaml.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Xamarin.Forms; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +namespace Xamarin.Forms.Controls.Issues +{ +#if APP + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 45284, "[iOS10] Extra tab icons display in iOS when binding Title on TabbedPage", PlatformAffected.iOS)] + public partial class Bugzilla45284 : TabbedPage + { + public Bugzilla45284() + { + var model = new Bugzilla45284Model(); + InitializeComponent(); + BindingContext = model; + model.Change(); + } + } + + public class Bugzilla45284Model : INotifyPropertyChanged + { + public List Tabs => new List { + new Bugzilla45284TabModel(), + new Bugzilla45284TabModel(), + new Bugzilla45284TabModel(), + new Bugzilla45284TabModel(), + new Bugzilla45284TabModel(), + new Bugzilla45284TabModel(), + new Bugzilla45284TabModel(), + }; + + public event PropertyChangedEventHandler PropertyChanged; + public void Change() + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Tabs))); + } + } + + public class Bugzilla45284TabModel + { + public string Title { get; set; } = "Title"; + public string Icon { get; set; } = "bank.png"; + } +#endif +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index c4594010c60..37b2c67268d 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -484,6 +484,9 @@ + + Bugzilla45284.xaml + @@ -593,6 +596,9 @@ MSBuild:UpdateDesignTimeXaml + + MSBuild:UpdateDesignTimeXaml + diff --git a/Xamarin.Forms.Platform.iOS/Forms.cs b/Xamarin.Forms.Platform.iOS/Forms.cs index 2c8fc6f7dc5..77ad6aeddc5 100644 --- a/Xamarin.Forms.Platform.iOS/Forms.cs +++ b/Xamarin.Forms.Platform.iOS/Forms.cs @@ -26,6 +26,8 @@ public static class Forms static bool? s_isiOS9OrNewer; + static bool? s_isiOS10OrNewer; + static Forms() { if (nevertrue) @@ -44,6 +46,16 @@ internal static bool IsiOS9OrNewer } } + internal static bool IsiOS10OrNewer + { + get + { + if (!s_isiOS10OrNewer.HasValue) + s_isiOS10OrNewer = UIDevice.CurrentDevice.CheckSystemVersion(10, 0); + return s_isiOS10OrNewer.Value; + } + } + public static void Init() { if (IsInitialized) diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs index 27492768490..30182c5631c 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs @@ -171,7 +171,9 @@ void HandleFinishedCustomizingViewControllers(object sender, UITabBarCustomizeCh void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e) { - if (e.PropertyName == Page.TitleProperty.PropertyName) + // Setting TabBarItem.Title in iOS 10 causes rendering bugs + // Work around this by creating a new UITabBarItem on each change + if (e.PropertyName == Page.TitleProperty.PropertyName && !Forms.IsiOS10OrNewer) { var page = (Page)sender; var renderer = Platform.GetRenderer(page); @@ -181,7 +183,7 @@ void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e) if (renderer.ViewController.TabBarItem != null) renderer.ViewController.TabBarItem.Title = page.Title; } - else if (e.PropertyName == Page.IconProperty.PropertyName) + else if (e.PropertyName == Page.IconProperty.PropertyName || e.PropertyName == Page.TitleProperty.PropertyName && Forms.IsiOS10OrNewer) { var page = (Page)sender;