From bf30ba7f131a922dc7ef261a1171b8aee99a07dc Mon Sep 17 00:00:00 2001 From: applovinAsh Date: Wed, 10 Nov 2021 13:49:52 -0800 Subject: [PATCH] bug/bug_fix_nav_bar_color --- .../ALAppDelegate.m | 19 +++++++++++++++++ .../ALAppDelegate.swift | 21 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/AppLovin MAX Demo App - ObjC/AppLovin MAX Demo App - ObjC/ALAppDelegate.m b/AppLovin MAX Demo App - ObjC/AppLovin MAX Demo App - ObjC/ALAppDelegate.m index 0fe1bb01f9..efea929d8e 100644 --- a/AppLovin MAX Demo App - ObjC/AppLovin MAX Demo App - ObjC/ALAppDelegate.m +++ b/AppLovin MAX Demo App - ObjC/AppLovin MAX Demo App - ObjC/ALAppDelegate.m @@ -21,6 +21,25 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( // AppLovin SDK is initialized, start loading ads now or later if ad gate is reached }]; + UIColor *barTintColor = [UIColor colorWithRed: 10/255.0 green: 131/255.0 blue: 170/255.0 alpha: 1.0]; + if ( @available(iOS 15.0, *) ) + { + UINavigationBarAppearance *navigationBarAppearance = [[UINavigationBarAppearance alloc] init]; + [navigationBarAppearance configureWithOpaqueBackground]; + navigationBarAppearance.backgroundColor = barTintColor; + navigationBarAppearance.titleTextAttributes = @{NSForegroundColorAttributeName : UIColor.whiteColor}; + [UINavigationBar appearance].standardAppearance = navigationBarAppearance; + [UINavigationBar appearance].scrollEdgeAppearance = navigationBarAppearance; + [UINavigationBar appearance].tintColor = UIColor.whiteColor; + } + else + { + // Fallback on earlier versions + [UINavigationBar appearance].barTintColor = barTintColor; + [UINavigationBar appearance].titleTextAttributes = @{NSForegroundColorAttributeName : UIColor.whiteColor}; + [UINavigationBar appearance].tintColor = UIColor.whiteColor; + } + return YES; } diff --git a/AppLovin MAX Demo App - Swift/AppLovin MAX Demo App - Swift/ALAppDelegate.swift b/AppLovin MAX Demo App - Swift/AppLovin MAX Demo App - Swift/ALAppDelegate.swift index 1f7bb72b2e..f4805cda71 100644 --- a/AppLovin MAX Demo App - Swift/AppLovin MAX Demo App - Swift/ALAppDelegate.swift +++ b/AppLovin MAX Demo App - Swift/AppLovin MAX Demo App - Swift/ALAppDelegate.swift @@ -23,6 +23,27 @@ class ALAppDelegate: UIResponder, UIApplicationDelegate // AppLovin SDK is initialized, start loading ads now or later if ad gate is reached }) + let barTintColor = UIColor.init(red: 10/255.0, green: 131/255.0, blue: 170/255.0, alpha: 1.0) + let navigationBarAppearance = UINavigationBar.appearance() + if #available(iOS 15.0, *) + { + let appearance = UINavigationBarAppearance() + appearance.configureWithOpaqueBackground() + appearance.backgroundColor = barTintColor + appearance.titleTextAttributes = [.foregroundColor : UIColor.white] + navigationBarAppearance.standardAppearance = appearance + navigationBarAppearance.scrollEdgeAppearance = appearance + navigationBarAppearance.tintColor = .white + } + else + { + // Fallback on earlier versions + navigationBarAppearance.isTranslucent = false + navigationBarAppearance.barTintColor = barTintColor + navigationBarAppearance.titleTextAttributes = [.foregroundColor : UIColor.white] + navigationBarAppearance.tintColor = .white + } + return true } }