iOS9的导航栏中的自定义字体MFMailComposeViewController?

好的,这是我到目前为止

正如你可以注意到,我设法改变字体大小,所以这是很好的,但我想要的样式也包括一个自定义的字体.

Note that the actual style is shown for a moment and then as the statusbar changes to black font the custom font gets losts.

这是我在我的applicationDidFinish中使用的代码

UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.LightContent

UINavigationBar.appearance().titleTextAttributes = [
     NSFontAttributeName: UIFont(name: "<MyCustomFont>",size: 32)!,NSForegroundColorAttributeName : UIColor.whiteColor(),]

UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().opaque = true
UINavigationBar.appearance().barStyle = UIBarStyle.Black
UINavigationBar.appearance().barTintColor = UIColor.BlueColor()

UIBarButtonItem.appearance().tintColor = UIColor.whiteColor()

UIBarButtonItem.appearance().setTitleTextAttributes([
     NSFontAttributeName: UIFont(name: "<MyCustomFont>",size: 18)!,],forState: UIControlState.normal)

Note:

I have an instance of EKEventEditViewController in place and the style is applied correctly.

The issue appears to be MailComposer’s related

解决方法

代码没有问题.当它适用于EKEventEditViewController的实例时,这是完全正当的,它不适用于MFMailComposeViewController的实例

如何进一步调查?

>也许尝试在不同版本的iOS上运行.如果你的应用程序
支持iOS8或更低版本,尝试看看它是否在那里工作.那样你
可以确保它是iOS9的具体问题.
>如果您有Xcode8测试版,您应该能够看到是否在iOS10中修复.

iOS9上仍然存在问题.在这种情况下,您需要在这里寻找替代品.您可能已经完全检查了UINavigationBar API,我建议您再次查看UINavigationItem API.它暴露了一个titleView属性,留下你想要的样子.

var titleView: UIView?

If this property value is nil,the navigation item’s title is displayed in the center of the navigation bar when the receiver is the top item. If you set this property to a custom title,it is displayed instead of the title.

Custom views can contain buttons. Use the buttonWithType: method in
UIButton class to add buttons to your custom view in the style of the
navigation bar. Custom title views are centered on the navigation bar
and may be resized to fit.

The default value is nil.

一个典型的用例 –

self.navigationItem.titleView = myCustomTitleView

优势: –

打开更多的可能性除了为UINavigationBar提供的有限定制终点

我需要你验证这是否有效.我还没有尝试过

希望它有帮助.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...