Change title color of navigation bar in MFMailComposeViewController in iOS 12 not working [duplicate]
/// UINavigationBar let navBarAppearance = UINavigationBar.appearance() navBarAppearance.barTintColor = .red navBarAppearance.tintColor = .white navBarAppearance.backgroundColor = .red navBarAppearance.titleTextAttributes = [ .foregroundColor: UIColor.white, .font: UIFont.systemFontSize ] navBarAppearance.largeTitleTextAttributes = [ .foregroundColor: UIColor.white, .font: UIFont.smallSystemFontSize ] let barButtonAppearance = UIBarButtonItem.appearance() barButtonAppearance.setTitleTextAttributes([.font: UIFont.systemFontSize], for: .normal) navBarAppearance.isTranslucent = false if #available(iOS 13.0, *) { let appearance = UINavigationBarAppearance() appearance.configureWithOpaqueBackground() appearance.backgroundColor = navBarAppearance.backgroundColor appearance.titleTextAttributes = navBarAppearance.titleTextAttributes ?? [:] appearance.largeTitleTextAttributes = navBarAppearance.largeTitleTextAttributes ?? [:] navBarAppearance.standardAppearance = appearance navBarAppearance.scrollEdgeAppearance = appearance }
I tried all the way to change the title color, however it doesn't work
Before presenting the mailcomopser controller
I changed the background color to white
and buttons color to black
Here is the code below:
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: UIBarPosition.any, barMetrics: UIBarMetrics.default)UINavigationBar.appearance().shadowImage = UIImage()UINavigationBar.appearance().tintColor = UIColor.whiteUINavigationBar.appearance().barTintColor = UIColor.whiteUINavigationBar.appearance().isTranslucent = falseUINavigationBar.appearance().clipsToBounds = falseUINavigationBar.appearance().backgroundColor = UIColor.whiteUIBarButtonItem.appearance().setTitleTextAttributes([.foregroundColor: UIColor.black], for: .normal)UIBarButtonItem.appearance().setTitleTextAttributes([.foregroundColor: UIColor.black], for: .highlighted)UIBarButtonItem.appearance().setTitleTextAttributes([.foregroundColor: UIColor.clear], for: .disabled)UIBarButtonItem.appearance().setTitleTextAttributes([.foregroundColor: UIColor.black], for: .selected)
In your AppDelegate.swift file in the didFinishLaunchingWithOptions launchOptions block
TRY THIS:
let navigationBarAppearace = UINavigationBar.appearance() navigationBarAppearace.barTintColor = .blue //your desired color navigationBarAppearace.tintColor = .white //your button etc color navigationBarAppearace.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white] //your Title Text color