更改iOS 12中MFMailComposeViewController中导航栏的标题颜色不起作用 [英] Change title color of navigation bar in MFMailComposeViewController in iOS 12 not working

查看:266
本文介绍了更改iOS 12中MFMailComposeViewController中导航栏的标题颜色不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改iOS 12MFMailComposeViewControllerUINavigationBar的标题颜色?

How can I change the title color of UINavigationBar in MFMailComposeViewController in iOS 12?

这就是我在做什么:

import MessageUI

extension MFMailComposeViewController {
    open override func viewDidLoad() {
        super.viewDidLoad()
        navigationBar.isTranslucent = false
        navigationBar.isOpaque = false
        navigationBar.barTintColor = .white
        navigationBar.tintColor = .white
        navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
    }
}

在iOS 10中工作:

In iOS 10 works:

在iOS 11中工作:

In iOS 11 works:

在iOS 12中无法正常工作:

In iOS 12 is not working:

推荐答案

我一直尝试更改标题颜色,但是不起作用

I tried all the way to change the title color, however it doesn't work

在展示mailcomopser控制器之前

Before presenting the mailcomopser controller

我将背景色更改为白色

,按钮颜色变为黑色

这是下面的代码:

UINavigationBar.appearance().setBackgroundImage(UIImage(), for: UIBarPosition.any, barMetrics: UIBarMetrics.default)
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().tintColor = UIColor.white
UINavigationBar.appearance().barTintColor = UIColor.white
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().clipsToBounds = false
UINavigationBar.appearance().backgroundColor = UIColor.white
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.black], for: .normal)
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.black], for: .highlighted)
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.clear], for: .disabled)
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.black], for: .selected)

这篇关于更改iOS 12中MFMailComposeViewController中导航栏的标题颜色不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆