eclipse导航栏字体大小设置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了eclipse导航栏字体大小设置相关的知识,希望对你有一定的参考价值。

参考技术A 方法:
1、进入eclipse,然后点击任务栏的“window”。
2、然后点击下面的“colorsandfonts”。
3、再点击下面的“textfont”。
4、最后就可以更改字体和字体的大小。

如何设置导航栏标题的字体大小

【中文标题】如何设置导航栏标题的字体大小【英文标题】:How to set the font size of navigation bar title 【发布时间】:2016-01-30 14:37:35 【问题描述】:

我尝试设置导航标题和其他项目的字体大小。 我该怎么做?

有很多答案提示我们可以使用方法 uinavigationbar.setTitleTextAttributes 设置它,但是这个方法不存在(不再存在)

有人知道怎么做吗?

navigationBar = UINavigationBar(frame: CGRectMake(0, 0, fDialogWidth, navbarHeigth))
        let navigationItem = UINavigationItem()
        navigationItem.title = sTitle;
        // Create left and right button for navigation item
        let leftButton = UIBarButtonItem(title: sBacklabel, style: UIBarButtonItemStyle.Plain, target: self, action: "backAction:")
        let rightButton = UIBarButtonItem(title: saddBookmark, style: UIBarButtonItemStyle.Plain, target: self, action: "addBookmarkAction:")



        // Create two buttons for the navigation item
        navigationItem.leftBarButtonItem = leftButton
        navigationItem.rightBarButtonItem = rightButton
        navigationBar.items = [navigationItem];

        navigationBar.frame = CGRectMake(0, 0, screenwidth, navbarHeigth);

【问题讨论】:

【参考方案1】:

将这些行添加到您的 viewDidLoad() 方法中:

self.navigationController?.navigationBar.topItem?.title = "Your title" 
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Your Font", size: 34)!, NSForegroundColorAttributeName: UIColor.whiteColor()]

【讨论】:

【参考方案2】:

swift 4 更新

大概你想为 UINavigationbar 设置系统字体大小 30 和黄色的标题。语法可能如下所示:

navigationItem.title = "Your Title"    
navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 30),NSAttributedStringKey.foregroundColor: UIColor.yellow]

【讨论】:

【参考方案3】:

试试这个...

 let titleAttributes = [
        NSFontAttributeName: UIFont(name: "your font name", size: 15)!
    ]
 self.navigationController?.navigationBar.titleTextAttributes = titleAttributes

如果你使用的是系统字体那么

 let titleAttributes = [
        NSFontAttributeName: UIFont.systemFontOfSize(15)
 ]
 self.navigationController?.navigationBar.titleTextAttributes = titleAttributes

【讨论】:

以上是关于eclipse导航栏字体大小设置的主要内容,如果未能解决你的问题,请参考以下文章

IOS设置导航栏字体大小及颜色

Eclipse怎么设置字体大小?

eclipse怎样设置字体大小

eclipse怎么设置字体大小

Eclipse怎样设置字体和文字的大小?操作方法是啥?

如何调整eclipse字体大小