1

Is still possible to change statusbar color on certain page by using angular2/nativescript?

I tried to use this way from docs but it doesn't work.

import { topmost } from "tns-core-modules/ui/frame";

if (topmost().ios) {
   var navigationBar = topmost().ios.controller.navigationBar;
   // 0: default
   // 1: light
   navigationBar.barStyle = 1;
}

Playground example is here: https://play.nativescript.org/?template=play-ng&id=z8CnAz

PS: I need to have black status bar on first page and white on second one. Is it possible?

Roman Šimr
  • 81
  • 1
  • 10

2 Answers2

0

You have to set UIViewControllerBasedStatusBarAppearance key to true in your info.plist

<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>
Manoj
  • 21,753
  • 3
  • 20
  • 41
0

You could set load event to ActionBar with next handler:

export function onActionBarLoaded(args: EventData) {
    const actionBar = <ActionBar>args.object;

    if (actionBar.ios) {
        var navigationBar = actionBar.page.frame.ios.controller.navigationBar;
        navigationBar.barStyle = 1;
    }
}

Test playground.

ych
  • 1,946
  • 2
  • 10
  • 15
  • but what to do if I want to have actionbar hidden? – Roman Šimr Apr 16 '19 at 11:03
  • In iOS if you hide ActionBar then StatusBar lose it background. Have you read [NativeScript 5.0 iOS Safe Area Support](https://www.nativescript.org/blog/nativescript-5-ios-safe-area-support)? – ych Apr 16 '19 at 15:07