Ios 缩小UINavicationBar大标题文本的大小

Ios 缩小UINavicationBar大标题文本的大小,ios,swift,uinavigationbar,ios11,Ios,Swift,Uinavigationbar,Ios11,在iOS 11之前,为了制作自定义标签,我只做了以下操作: let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 40)) titleLabel.text = self.customTitleText titleLabel.backgroundColor = .clear titleLabel.textAlignment = .left titleLab

在iOS 11之前,为了制作自定义标签,我只做了以下操作:

let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: 40))
titleLabel.text = self.customTitleText
titleLabel.backgroundColor = .clear
titleLabel.textAlignment = .left
titleLabel.textColor = .white
titleLabel.font = UIFont.boldSystemFont(ofSize: 17)
titleLabel.adjustsFontSizeToFitWidth = true
titleLabel.minimumScaleFactor = 0.25
navigationItem.titleView = titleLabel

现在,标题视图似乎不会影响大标题。如何在iOS 11中实现文本压缩?

您可以这样使用:

self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.largeTitleTextAttributes = [
        NSAttributedStringKey.foregroundColor: UIColor.red,
        NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 17)
    ]

您可以这样使用:

self.navigationController?.navigationBar.prefersLargeTitles = true
self.navigationController?.navigationBar.largeTitleTextAttributes = [
        NSAttributedStringKey.foregroundColor: UIColor.red,
        NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 17)
    ]

多大尺寸?你能解释更多吗?字体大小(即计算屏幕宽度的正确字体大小)是哪种大小?你能解释更多吗?字体大小(即计算屏幕宽度的正确字体大小)你找到解决方案了吗?你找到解决方案了吗?