Bug 37431 - NavigationRenderer sets Status Bar Style arbitrarily
Summary: NavigationRenderer sets Status Bar Style arbitrarily
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS (show other bugs)
Version: 2.0.0
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-01-06 02:55 UTC by david
Modified: 2016-11-16 20:18 UTC (History)
3 users (show)

See Also:
Tags: ac
Is this bug a regression?: ---
Last known good build:


Description david 2016-01-06 02:55:04 UTC
The following code in the "UpdateBarTextColor" method of the stock NavigationRenderer causes the iOS status bar to be set incorrectly:

		private void UpdateBarTextColor ()
			Color barTextColor = ((NavigationPage)this.Element).BarTextColor;
			UITextAttributes titleTextAttributes = UINavigationBar.Appearance.GetTitleTextAttributes ();
			if (barTextColor == Color.Default) {
				if (this.NavigationBar.TitleTextAttributes != null) {
					UIStringAttributes uIStringAttributes = new UIStringAttributes ();
					uIStringAttributes.ForegroundColor = titleTextAttributes.TextColor;
					uIStringAttributes.Font = titleTextAttributes.Font;
					this.NavigationBar.TitleTextAttributes = uIStringAttributes;
			else {
				UIStringAttributes uIStringAttributes2 = new UIStringAttributes ();
				uIStringAttributes2.Font = titleTextAttributes.Font;
				uIStringAttributes2.ForegroundColor = ((barTextColor == Color.Default) ? (uIStringAttributes2.ForegroundColor ?? UINavigationBar.Appearance.TintColor) : barTextColor.ToUIColor ());
				this.NavigationBar.TitleTextAttributes = uIStringAttributes2;
			if (Forms.IsiOS7OrNewer) {
				this.NavigationBar.TintColor = ((barTextColor == Color.Default) ? UINavigationBar.Appearance.TintColor : barTextColor.ToUIColor ());

			if (barTextColor.Luminosity > 0.5) {
				UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.BlackTranslucent;
			UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.Default;

The code sets the StatusBarStyle according to the luminosity of the barTextColor.

Unfortunately this breaks all kinds of useful and attractive interfaces where (for example) we need a light-colored text on a white background WITH A BLACK STATUS BAR.

Please do not make this kind of configuration decision without providing some kind of override. I'm now stuck, unable to implement the designer's desired look, because this code sets my status bar text to white irrespective of anything else I try to do in a custom renderer.
Comment 1 Samantha Houts [MSFT] 2016-10-29 00:44:28 UTC
*** Bug 44777 has been marked as a duplicate of this bug. ***
Comment 2 Samantha Houts [MSFT] 2016-11-16 20:18:50 UTC
Should be fixed in 2.3.4-pre1. Please note that this is an opt-in fix. Please see https://github.com/xamarin/Xamarin.Forms/pull/517 for an example of disabling this behavior. Thank you!

Note You need to log in before you can comment on or make changes to this bug.