Xcode"导航栏"字体问题

时间:2016-04-21 07:15:12

标签: ios xcode fonts

我的问题是导航栏的标题不会采用自定义字体。我认为字体有效,因为标签和按钮字体没有问题。字体在" main.storyboard"中看起来很好,但是当我运行模拟器或将应用程序安装到我的手机时,导航栏中的字体不正确。请看下面的图片。有没有人遇到过同样的问题?

我正在使用Xcode 7.2.1。用SWIFT写作

Screen shot: main.storyboard

Screen shot: simulator

2 个答案:

答案 0 :(得分:1)

请不要在代码中的某处覆盖字体设置?您也可以尝试按代码设置 - 例如:

UINavigationBar.appearance().titleTextAttributes = [
    NSFontAttributeName: UIFont(name: "ProximaNova-Semibold", size: 18)!,
    NSForegroundColorAttributeName : UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 1),
    NSBackgroundColorAttributeName: UIColor.whiteColor()
]

答案 1 :(得分:1)

设置导航栏标题字体如下:

目标C:

[[UINavigationBar appearance]setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"VarelaRound" size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];

夫特:

 UINavigationBar.appearance().titleTextAttributes = [    NSFontAttributeName: UIFont(name: "VarelaRound", size: 18)!]

在info.plist中添加以下内容以在您的应用程序中使用字体。

enter image description here

希望有所帮助......

相关问题