我尝试设置导航标题和其他项目的字体大小。
我怎样才能做到这一点 ?

有很多答案,我们可以使用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);

最佳答案

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

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

关于ios - 如何设置导航栏标题的字体大小,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33431421/

10-12 00:22
查看更多