summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorSamantha Houts <samantha@teamredwall.com>2016-06-28 03:25:45 -0700
committerRui Marinho <me@ruimarinho.net>2016-06-28 11:25:45 +0100
commit0772a5278b96f289ff216f10da86b072bc6edbf1 (patch)
treedbf54e33abc93749d230b6ba6996abcd653f5d89 /Xamarin.Forms.Platform.iOS
parent589adbd3ef145ec85f9fe64eda008251c1cdb745 (diff)
downloadxamarin-forms-0772a5278b96f289ff216f10da86b072bc6edbf1.tar.gz
xamarin-forms-0772a5278b96f289ff216f10da86b072bc6edbf1.tar.bz2
xamarin-forms-0772a5278b96f289ff216f10da86b072bc6edbf1.zip
[iOS] Default BarTextColor/BarBackgroundColor will no longer override values set in custom renderers (#233)beta-2.3.1-pre1
* [Controls] Improve TabbedPage test case iOS should default to the color used in a custom renderer instead of to the global default color. * [iOS] TabbedPage Bar*Color default is better Will use the color set by a custom renderer, if any, instead of always pulling from global appearance.
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs48
1 files changed, 41 insertions, 7 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs
index 25fceb41..695ce2ac 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/TabbedRenderer.cs
@@ -24,6 +24,12 @@ namespace Xamarin.Forms.Platform.iOS
{
public class TabbedRenderer : UITabBarController, IVisualElementRenderer, IEffectControlProvider
{
+ bool _barBackgroundColorWasSet;
+ bool _barTextColorWasSet;
+ UIColor _defaultBarTextColor;
+ bool _defaultBarTextColorSet;
+ UIColor _defaultBarColor;
+ bool _defaultBarColorSet;
bool _loaded;
Size _queuedSize;
@@ -309,14 +315,31 @@ namespace Xamarin.Forms.Platform.iOS
return;
var barBackgroundColor = Tabbed.BarBackgroundColor;
+ var isDefaultColor = barBackgroundColor.IsDefault;
+
+ if (isDefaultColor && !_barBackgroundColorWasSet)
+ return;
+
+ if (!_defaultBarColorSet)
+ {
+ if (Forms.IsiOS7OrNewer)
+ _defaultBarColor = TabBar.BarTintColor;
+ else
+ _defaultBarColor = TabBar.TintColor;
+
+ _defaultBarColorSet = true;
+ }
+
+ if (!isDefaultColor)
+ _barBackgroundColorWasSet = true;
if (Forms.IsiOS7OrNewer)
{
- TabBar.BarTintColor = barBackgroundColor == Color.Default ? UINavigationBar.Appearance.BarTintColor : barBackgroundColor.ToUIColor();
+ TabBar.BarTintColor = isDefaultColor ? _defaultBarColor : barBackgroundColor.ToUIColor();
}
else
{
- TabBar.TintColor = barBackgroundColor == Color.Default ? UINavigationBar.Appearance.TintColor : barBackgroundColor.ToUIColor();
+ TabBar.TintColor = isDefaultColor ? _defaultBarColor : barBackgroundColor.ToUIColor();
}
}
@@ -326,13 +349,24 @@ namespace Xamarin.Forms.Platform.iOS
return;
var barTextColor = Tabbed.BarTextColor;
+ var isDefaultColor = barTextColor.IsDefault;
+
+ if (isDefaultColor && !_barTextColorWasSet)
+ return;
+
+ if (!_defaultBarTextColorSet)
+ {
+ _defaultBarTextColor = TabBar.TintColor;
+ _defaultBarTextColorSet = true;
+ }
- var globalAttributes = UINavigationBar.Appearance.GetTitleTextAttributes();
+ if (!isDefaultColor)
+ _barTextColorWasSet = true;
- var attributes = new UITextAttributes { Font = globalAttributes.Font };
+ var attributes = new UITextAttributes();
- if (barTextColor == Color.Default)
- attributes.TextColor = globalAttributes.TextColor;
+ if (isDefaultColor)
+ attributes.TextColor = _defaultBarTextColor;
else
attributes.TextColor = barTextColor.ToUIColor();
@@ -345,7 +379,7 @@ namespace Xamarin.Forms.Platform.iOS
// setting the unselected icon tint is not supported by iOS
if (Forms.IsiOS7OrNewer)
{
- TabBar.TintColor = barTextColor == Color.Default ? UINavigationBar.Appearance.TintColor : barTextColor.ToUIColor();
+ TabBar.TintColor = isDefaultColor ? _defaultBarTextColor : barTextColor.ToUIColor();
}
}