From 2b8783e9eb97c1ed627dcf7b3413543bf9c5907d Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Thu, 2 Sep 2021 22:35:09 +0200 Subject: [PATCH] fix(ios): backport: actionBar to use appearance api on ios13+ (#9530) --- packages/core/ui/action-bar/index.ios.ts | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/core/ui/action-bar/index.ios.ts b/packages/core/ui/action-bar/index.ios.ts index 6dc494478..c430b76c4 100644 --- a/packages/core/ui/action-bar/index.ios.ts +++ b/packages/core/ui/action-bar/index.ios.ts @@ -349,7 +349,7 @@ export class ActionBar extends ActionBarBase { this.setColor(navBar, color); const bgColor = this.backgroundColor; - navBar.barTintColor = bgColor ? bgColor.ios : null; + this.setBackgroundColor(navBar, bgColor); } private setColor(navBar: UINavigationBar, color?: Color) { @@ -371,6 +371,25 @@ export class ActionBar extends ActionBarBase { } } + private setBackgroundColor(navBar: UINavigationBar, color?: UIColor | Color) { + if (!navBar) { + return; + } + + const color_ = color instanceof Color ? color.ios : color; + if (majorVersion >= 13) { + const appearance = navBar.standardAppearance ?? UINavigationBarAppearance.new(); + // appearance.configureWithOpaqueBackground(); + appearance.backgroundColor = color_; + navBar.standardAppearance = appearance; + navBar.compactAppearance = appearance; + navBar.scrollEdgeAppearance = appearance; + } else { + // legacy styling + navBar.barTintColor = color_; + } + } + public _onTitlePropertyChanged() { const page = this.page; if (!page) { @@ -467,12 +486,9 @@ export class ActionBar extends ActionBarBase { // CssAnimationProperty use default value form their constructor. return null; } - [backgroundColorProperty.setNative](value: UIColor | Color) { + [backgroundColorProperty.setNative](color: UIColor | Color) { const navBar = this.navBar; - if (navBar) { - const color = value instanceof Color ? value.ios : value; - navBar.barTintColor = color; - } + this.setBackgroundColor(navBar, color); } [backgroundInternalProperty.getDefault](): UIColor {