Skip to content

Commit 2bfccbb

Browse files
rigor789NathanWalker
authored andcommitted
fix(ios): actionBar to use appearance api on ios13+ (#9530)
1 parent e4c0ed3 commit 2bfccbb

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

packages/core/ui/action-bar/index.ios.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export class ActionBar extends ActionBarBase {
349349
this.setColor(navBar, color);
350350

351351
const bgColor = <Color>this.backgroundColor;
352-
navBar.barTintColor = bgColor ? bgColor.ios : null;
352+
this.setBackgroundColor(navBar, bgColor);
353353
}
354354

355355
private setColor(navBar: UINavigationBar, color?: Color) {
@@ -371,6 +371,25 @@ export class ActionBar extends ActionBarBase {
371371
}
372372
}
373373

374+
private setBackgroundColor(navBar: UINavigationBar, color?: UIColor | Color) {
375+
if (!navBar) {
376+
return;
377+
}
378+
379+
const color_ = color instanceof Color ? color.ios : color;
380+
if (majorVersion >= 13) {
381+
const appearance = navBar.standardAppearance ?? UINavigationBarAppearance.new();
382+
// appearance.configureWithOpaqueBackground();
383+
appearance.backgroundColor = color_;
384+
navBar.standardAppearance = appearance;
385+
navBar.compactAppearance = appearance;
386+
navBar.scrollEdgeAppearance = appearance;
387+
} else {
388+
// legacy styling
389+
navBar.barTintColor = color_;
390+
}
391+
}
392+
374393
public _onTitlePropertyChanged() {
375394
const page = this.page;
376395
if (!page) {
@@ -467,12 +486,9 @@ export class ActionBar extends ActionBarBase {
467486
// CssAnimationProperty use default value form their constructor.
468487
return null;
469488
}
470-
[backgroundColorProperty.setNative](value: UIColor | Color) {
489+
[backgroundColorProperty.setNative](color: UIColor | Color) {
471490
const navBar = this.navBar;
472-
if (navBar) {
473-
const color = value instanceof Color ? value.ios : value;
474-
navBar.barTintColor = color;
475-
}
491+
this.setBackgroundColor(navBar, color);
476492
}
477493

478494
[backgroundInternalProperty.getDefault](): UIColor {

0 commit comments

Comments
 (0)