The action bar is required to change the color of the status bar text.
iOS
CLI: 2.01
new project (tns create statusbar)
Code to change status text to white:
if (page.ios) {
var navigationBar = frameModule.topmost().ios.controller.navigationBar;
navigationBar.barStyle = 1;
navigationBar.tintColor = UIColor.whiteColor();
}
add this action bar code to main-page.xml
<Page.actionBar>
<ActionBar title="Title" icon="">
<NavigationButton text="Back" icon="" tap="" />
<ActionBar.actionItems>
<ActionItem icon="" text="Left" tap="" ios.position="left" />
<ActionItem icon="" text="Right" tap="" ios.position="right" />
</ActionBar.actionItems>
</ActionBar>
</Page.actionBar>
once you have the action bar code in, you will see the color go to white. if you remove the action bar code you will see the white text goes away and it goes back to black.
if we could chose white/black and set background to transparent even with out an action bar that would be awesome.
DEMO APP with everything in it: statusBar.zip
Hi @firescript,
Thank your for reporting your problem.
I reviewed your issue and found that you could not style StatusBar with navigationBar.barStyle = 1; when you do not have ActionBarin your xml file. However I found that there is one easy way to set different StatusBar style to your application. You could add in your app/App_Resources/iOS/Info.plist following lines
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
before closing </dict> tag. In regard to that you should set backgroundColor to your page and to set page.backgroundSpanUnderStatusBar to true. I am attaching example bellow:
main-page.xml
<Page navigatedTo="navigatingTo" backgroundColor="red">
<Label text="sample status bar style" />
</Page>
main-page.js
function navigatingTo(args) {
var page = args.object;
page.backgroundSpanUnderStatusBar = true;
}
exports.navigatingTo = navigatingTo;
I hope this helps.
Any chance we could add this to the official docs before closing? It's gonna keep coming up again and again.
Is it possible to dynamically change the iOS statusbar text color, while, again, not using the ActionBar?
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hi @firescript,
Thank your for reporting your problem.
I reviewed your issue and found that you could not style StatusBar with
navigationBar.barStyle = 1;when you do not haveActionBarin your xml file. However I found that there is one easy way to set different StatusBar style to your application. You could add in yourapp/App_Resources/iOS/Info.plistfollowing linesbefore closing
</dict>tag. In regard to that you should setbackgroundColorto your page and to setpage.backgroundSpanUnderStatusBartotrue. I am attaching example bellow:main-page.xml
main-page.js
I hope this helps.