ios - 导航标题用外部字体切碎 'FuturaStd-Book'

标签 ios objective-c uinavigationcontroller navigation uinavigationitem

Navigation Item Title Chopped

导航中使用外部字体“FuturaStd-Book”截断的标题。

尝试使用以下代码减小字体大小,但标题仍然被截断。

[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"FuturaStd-Book" size:16]}];

请帮我解决这个...

最佳答案

以下代码对齐 navigationItem 标题。 (仅适用于 iOS 11 - 但向后导航和标题 y 位置不同)

NSMutableParagraphStyle *style =  [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
style.alignment = NSTextAlignmentCenter;
style.firstLineHeadIndent = 1.0f;
style.lineSpacing = 2; //Change spacing between lines
style.paragraphSpacing = 2; //Change space between paragraphs        

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor],
                                                               NSBackgroundColorAttributeName:[UIColor clearColor],
                                                               NSFontAttributeName:[UIFont fontWithName:@"FuturaStd-Book" size:18],
                                                               NSParagraphStyleAttributeName: style }];

关于ios - 导航标题用外部字体切碎 'FuturaStd-Book',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48088812/

相关文章:

ios - 你如何清除 Xcode 4.X 中的旧引用

ios - swift - 警告 : Attempt to present * on * while a presentation is in progress

ios - 自己的 Promisekit promise 没有正确响应

ios - 在没有后退按钮的情况下推送到 ViewController

swift - UINavigationBar 不支持自定义 UIColor?

ios - 在ios7中用日期对NSMutableArray进行排序

ios - 使用 React Native 在 iOS 中获取本地文件

iphone - RestKit - 向所有请求附加参数

objective-c - NS条件死锁

ios - backBarbuttonitem 什么都不做?