Swift UIActivityViewController电子邮件主题行继承全局UINavigationBar字体更改

[英]Swift UIActivityViewController Email subject line inherits global UINavigationBar font change


I change the size and weight of the UINavigationBar font with the following:

我用以下内容更改了UINavigationBar字体的大小和重量:

UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black]
UINavigationBar.appearance().titleTextAttributes = [ NSAttributedStringKey.font: UIFont.systemFont(ofSize: 28, weight: .heavy)]

When I present the UIActivityViewController and select Mail, the subject line in the title (not the email) inherits the font change. In order to change this, I change the UINavigationBar back to something smaller.

当我呈现UIActivityViewController并选择Mail时,标题中的主题行(不是电子邮件)继承了字体更改。为了改变这种情况,我将UINavigationBar改回了更小的东西。

While this works, and the subject line in the title is smaller, and now readable, when the UIActivityViewController returns, naturally the UINavigationBar font is still set to the new size and weight. I tried the completion as per below, but the font doesn't resize.

虽然这有效,并且标题中的主题行较小,现在可读,但当UIActivityViewController返回时,UINavigationBar字体仍然设置为新的大小和权重。我尝试按照下面的方式完成,但字体没有调整大小。

@objc func showActivityViewController() {

     UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black]
     UINavigationBar.appearance().titleTextAttributes = [ NSAttributedStringKey.font: UIFont.systemFont(ofSize: 17, weight: .thin)]

     present(activityViewController, animated: true, completion: {

          UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black]
          UINavigationBar.appearance().titleTextAttributes = [ NSAttributedStringKey.font: UIFont.systemFont(ofSize: 28, weight: .heavy)]

        })
    }

enter image description here

1 个解决方案

#1


0  

I change the font color of a UIButton in a similar way. I found that using the main thread helped. Try this and see if it works:

我以类似的方式更改UIButton的字体颜色。我发现使用主线程有帮助。试试这个,看它是否有效:

 present(activityViewController, animated: true, completion: {
      DispatchQueue.main.async {
          UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.black]
          UINavigationBar.appearance().titleTextAttributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 28, weight: .heavy)]
      }
 })
智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2017/11/09/d4967973d1de32979c5f068bb5051a4f.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告