【问题标题】:MFMailComposeViewController Bar titleText and UIbarbuttons not using custom font provided by appearance proxyMFMailComposeViewController Bar titleText 和 UIbarbuttons 不使用外观代理提供的自定义字体
【发布时间】:2015-09-07 05:39:48
【问题描述】:

我已使用“applicationDidFinishLaunching”中的外观代理将 UIBarButtonItem 和 UINavigationBar titleTextAttributes 的外观更改为我的自定义字体,并将颜色更改为白色。每个导航标题文本和 BarButtonItems 都使用提供的自定义字体。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    application.setStatusBarStyle(UIStatusBarStyle.LightContent, animated: false)
    UINavigationBar.appearance().barStyle = UIBarStyle.BlackTranslucent
    UINavigationBar.appearance().barTintColor = NSFontAttributeName:SharedHelper.myCustomBarColor()
    UINavigationBar.appearance().titleTextAttributes =[NSForegroundColorAttributeName:UIColor.whiteColor()]

    UIBarButtonItem.appearance().tintColor = UIColor.whiteColor()
    let attributes = [NSFontAttributeName:SharedHelper.customFontForBarButton()]
    UIBarButtonItem.appearance().setTitleTextAttributes(attributes, forState: UIControlState.Normal)
    return true
}    

当我使用 MFMailComposeViewController 发送电子邮件时,问题就出现了。 MFMailComposeViewController 忽略字体属性并恢复为默认字体。在 iPhone 5S 模拟器中,我可以看到一段时间的自定义字体,但它会恢复为默认字体。

在 iPhone Simulator 5S 中显示了一段时间。 (我正在努力做到这一点)

几秒钟后使用默认字体。

对此有任何帮助吗?外观代理不应该也适用于 MFMailComposeViewController 的 UIBarButton 和 NavigationBar 吗?或者是否需要为此进行任何编码?

我正在使用 Swift,也尝试使用 Alexander 使用 Bridge 的外观WhenContainedIn,但似乎没有用。我关心的是更改 MFMailComposeViewController 的 titleText 和 BarButtonItems ( cancel, send ) 的字体。

提前致谢。任何帮助将不胜感激。

【问题讨论】:

  • 您好,我也遇到了同样的问题,您找到解决方法了吗?
  • @HugoAlonso:不,我最终使用了默认字体。

标签: ios iphone swift uikit mfmailcomposeviewcontroller


【解决方案1】:

在过去的几天里,我一直在与 iOS 9 设备作斗争。我几乎什么都试过了。但是,今天早上我将尝试将以下内容添加到 AppDelegate:

UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([MFComposeViewController.self]).setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.blueColor()], forState: .Normal)

我不能使用 UINavigationBar 类,因为它会影响整个应用程序的外观,这不是我想要的。

如果有效我会回帖。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-24
    相关资源
    最近更新 更多