标题字体在导航栏中不会更改

Gas*_*sim 7 storyboard uinavigationcontroller ios

我有一个嵌入在导航控制器中的控制器,我想在导航栏中更改标题的字体.我想使用故事板,因此它会在应用程序中发生变化(而不是为NavigationController创建文件并通过代码执行); 不是每个控制器:故事板

我可以更改字体大小和颜色,但在使用自定义字体时无法更改字体系列.在这种情况下,所有其他Xcode字体都有效.我在应用程序的任何地方都使用自定义字体,但只有在导航时才能使用.

这个问题可能是什么原因?

Cha*_*ang 11

我在Xcode 6.4中遇到了完全相同的问题.这可能是Xcode的一个错误.

目前,您可以做的是以编程方式设置自定义字体.(确保项目中有字体ttf文件,并在项目设置 - >信息 - >应用程序提供的字体中添加属性)

迅速:

self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "LeagueGothic-Regular", size: 16.0)!, 
                                                                 NSForegroundColorAttributeName: UIColor.whiteColor()]
Run Code Online (Sandbox Code Playgroud)

Objective-C的:

[[UINavigationBar appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
        [UIColor whiteColor], NSForegroundColorAttributeName, 
           [UIFont fontWithName:@"LeagueGothic-Regular" size:16.0], NSFontAttributeName,nil]];
Run Code Online (Sandbox Code Playgroud)