Adam Bardon
Adam Bardon

Reputation: 3889

MFMailComposeViewController navigationBar custom background color

I'm using MFMailComposeViewController and I'd like to change background color so it matches the one I have across the app. I've tried several things, but nothing worked(at least not on iOS 9).

let mailVC = MFMailComposeViewController()
mailVC.mailComposeDelegate = self
...

mailVC.navigationBar.titleTextAttributes =
[NSForegroundColorAttributeName: UIColor.whiteColor()] // this works
mailVC.navigationBar.tintColor = UIColor.whiteColor() // this works
mailVC.navigationBar.barTintColor = UIColor.blueColor()  // this doesn't work
mailVC.navigationBar.backgroundColor = UIColor.blueColor()  // this doesn't work

Background color stays default gray.

Upvotes: 5

Views: 1604

Answers (1)

Adam Bardon
Adam Bardon

Reputation: 3889

I solved it by setting color of navigationbar before initializing MFMailComposeViewController like this:

UINavigationBar.appearance().barTintColor = UIColor.blueColor()

let mailVC = MFMailComposeViewController()

Upvotes: 9

Related Questions