I look that I have found a workaround. Somehow setting composer.navigationBar.barTintColor and UINavigationBar.appearance().barTintColor does not work.
The workaround is to use UINavigationBar.appearance().setBackgroundImage(...) and set the UIImage to one color as the background
Full working code:
UINavigationBar.appearance().setBackgroundImage(UIImage.from(color: UIColor.green), for: .default) let composer = MFMessageComposeViewController() self?.present(composer, animated: true, completion: nil)
create UIImage one color:
extension UIImage { static func from(color: UIColor) -> UIImage { let rect = CGRect(x: 0, y: 0, width: 1, height: 1) UIGraphicsBeginImageContext(rect.size) let context = UIGraphicsGetCurrentContext() context!.setFillColor(color.cgColor) context!.fill(rect) let img = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return img! } }
source share