1
votes

I read in different articles that it's working, but somehow it doesn't for me. I added into plist

  <key>UIViewControllerBasedStatusBarAppearance</key>
  <false/>

And

  var p = new FreshNavigationContainer(page);
  p.BarTextColor = Color.Fuchsia;
  p.BarBackgroundColor = Color.Aqua;
  MainPage = p;

FreshNavigationContainer is derived from NavigationPage.

I want to have an ability to change the status bar color on each page. When a page is dark - I need status bar to be light. And vice versa.

1
Hi Vorotnyak! Is this problem only happening in iOS? Can you confirm whether it is also happening on the Android app? - Brandon Minnick
I've left an answer based on some guesses to what you are expecting. If you can update the question with more specifics as to what you want to change I will adjust my answer if needed. - therealjohn
Can you your share FreshNavigationContainer code? - Atul
@Atul This code isn't mine. Here github.com/rid00z/FreshMvvm - Vorotnyak_Nazar
@BrandonMinnick Now I only care about iOS - Vorotnyak_Nazar

1 Answers

3
votes

I think there is some confusion on exactly what you are trying to change the color of.

UIViewControllerBasedStatusBarAppearance is usually used in combination with changing the status bar text color. For example,

UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.LightContent, false);

That would make a change like this:

enter image description here

It looks like you might be expecting BarTextColor to change this. However, that changes the text "My Expenses" in the image above.

You'll have to change the status bar text color in the iOS project using an iOS API (not Forms). Sample here. If you want your entire app to have a light text color in the status bar, update your info.plist to:

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>

Update:

If you want to change the status bar color of each page, you need to set UIViewControllerBasedStatusBarAppearance to true. Then, you would need to use a PageRenderer in your iOS project for each page that you want to change the status bar color for. In the renderer, you can call UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent; in the ViewWillAppear method.

Keep in mind that you have limited options on the style, listed here.