OGeek|极客世界-中国程序员成长平台

标题: ios - UINavigationBar 字体属性似乎只调整标题,但不调整 View 部分 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 07:42
标题: ios - UINavigationBar 字体属性似乎只调整标题,但不调整 View 部分

我在 AppDelegate.m 中使用了以下内容来更改 UINavigationBar 的字体属性:

[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                           [UIColor darkBlue], NSForegroundColorAttributeName,
                                                           [UIFont fontWithName:SYSTEM_FONT_TYPE size:SYSTEM_FONT_SIZE*1.2], NSFontAttributeName, nil]];

但是,这似乎只调整了标题显示字体,而不是面包屑回溯部分:

menu image

查看类引用,我一定错过了它,因为除了与 TitleTextAttributes 相关的属性或方法之外,我没有看到任何其他可以引用的属性或方法。我还应该更改什么来更改左侧文本的字体?



Best Answer-推荐答案


UIBarButtonItem *backbutton =  [[UIBarButtonItem alloc] initWithTitle"Menu" style:UIBarButtonItemStyleBordered target:nil action:nil];    

[backbutton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor darkBlue],UITextAttributeTextColor,[UIFont fontWithName:TEXTFONT size:16.0f],UITextAttributeFont, nil] forState:UIControlStateNormal]; 

或者,

[[UIBarButtonItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor darkBlue],[UIFont fontWithName:TEXTFONT size:16.0f],UITextAttributeFont, nil] forState:UIControlStateNormal];

关于ios - UINavigationBar 字体属性似乎只调整标题,但不调整 View 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30575940/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4