Skip to content

Commit

Permalink
bug/bug_fix_nav_bar_color (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
applovinAsh authored Nov 10, 2021
1 parent ce018c5 commit f608bb8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit f608bb8

Please sign in to comment.