微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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提供的有限定制终点

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

希望它有帮助.

原文地址:https://www.jb51.cc/iOS/329895.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐