正如你可以注意到,我设法改变字体大小,所以这是很好的,但我想要的样式也包括一个自定义的字体.
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
解决方法
如何进一步调查?
>也许尝试在不同版本的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提供的有限定制终点
我需要你验证这是否有效.我还没有尝试过
希望它有帮助.