From 183b4d4b10a4ec7f9527e5373c8ce723c3db0c3e Mon Sep 17 00:00:00 2001 From: Jason Cassidy <47318351+jcassidyav@users.noreply.github.com> Date: Mon, 20 Sep 2021 19:12:08 +0100 Subject: [PATCH] fix(ios): flat property using new appearance api (#9558) --- packages/core/ui/action-bar/index.ios.ts | 35 ++++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/packages/core/ui/action-bar/index.ios.ts b/packages/core/ui/action-bar/index.ios.ts index ce1747e27..c30ff8b2c 100644 --- a/packages/core/ui/action-bar/index.ios.ts +++ b/packages/core/ui/action-bar/index.ios.ts @@ -406,14 +406,37 @@ export class ActionBar extends ActionBarBase { } private updateFlatness(navBar: UINavigationBar) { + if (this.flat) { - navBar.setBackgroundImageForBarMetrics(UIImage.new(), UIBarMetrics.Default); - navBar.shadowImage = UIImage.new(); - navBar.translucent = false; + + if (majorVersion >= 15) { + const appearance = navBar.standardAppearance ?? UINavigationBarAppearance.new(); + appearance.shadowColor = UIColor.clearColor; + + navBar.standardAppearance = appearance; + navBar.compactAppearance = appearance; + navBar.scrollEdgeAppearance = appearance; + } else { + + navBar.setBackgroundImageForBarMetrics(UIImage.new(), UIBarMetrics.Default); + navBar.shadowImage = UIImage.new(); + navBar.translucent = false; + } } else { - navBar.setBackgroundImageForBarMetrics(null, null); - navBar.shadowImage = null; - navBar.translucent = true; + if (majorVersion >= 15) { + if(navBar.standardAppearance){ // Not flat and never been set do nothing. + const appearance = navBar.standardAppearance; + appearance.shadowColor = UINavigationBarAppearance.new().shadowColor; + + navBar.standardAppearance = appearance; + navBar.compactAppearance = appearance; + navBar.scrollEdgeAppearance = appearance; + } + } else { + navBar.setBackgroundImageForBarMetrics(null, null); + navBar.shadowImage = null; + navBar.translucent = true; + } } }