feat(ios): ease of use on explicit preferredStatusBarStyle

Allows statusBarStyle to be defined on any view for explicit per view control, whether presented in modal or not.
Note: You must remove Info.plist key `UIViewControllerBasedStatusBarAppearance`
It defaults to true when not present: https://developer.apple.com/documentation/bundleresources/information-property-list/uiviewcontrollerbasedstatusbarappearance
Or you can explicitly set it to true:
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>

False value will make this property have no effect.
This commit is contained in:
Nathan Walker
2025-09-24 11:15:14 -07:00
parent d5467fd752
commit 5f022855e8
8 changed files with 58 additions and 21 deletions

View File

@@ -65,14 +65,6 @@ export declare class Page extends PageBase {
*/
public backgroundSpanUnderStatusBar: boolean;
/**
* Gets or sets the style of the status bar.
*
* @nsProperty
*/
// @ts-ignore
public statusBarStyle: 'light' | 'dark';
/**
* Gets or sets the color of the status bar in Android.
*

View File

@@ -349,7 +349,11 @@ class UIViewControllerImpl extends UIViewController {
public get preferredStatusBarStyle(): UIStatusBarStyle {
const owner = this._owner?.deref();
if (owner) {
return owner.statusBarStyle === 'dark' ? UIStatusBarStyle.LightContent : UIStatusBarStyle.Default;
if (SDK_VERSION >= 13) {
return owner.statusBarStyle === 'dark' ? UIStatusBarStyle.DarkContent : UIStatusBarStyle.LightContent;
} else {
return owner.statusBarStyle === 'dark' ? UIStatusBarStyle.LightContent : UIStatusBarStyle.Default;
}
} else {
return UIStatusBarStyle.Default;
}

View File

@@ -63,13 +63,6 @@ export class PageBase extends ContentView {
}
}
get statusBarStyle(): 'light' | 'dark' {
return this.style.statusBarStyle;
}
set statusBarStyle(value: 'light' | 'dark') {
this.style.statusBarStyle = value;
}
public get androidStatusBarBackground(): Color {
return this.style.androidStatusBarBackground;
}