[英]Trouble setting Navigation Bar Font and Size
I know this is very simple but I have looked everywhere and cannot find the answer to this. 我知道这很简单,但是我四处张望,找不到答案。 What I have found tells me to write this code, or similar code.
我发现的结果告诉我编写此代码或类似的代码。 And I have tried everything.
我已经尝试了一切。 I am using a Navigation Controller and I want to change the font and size of the text.
我正在使用导航控制器,并且想更改文本的字体和大小。 I have not been able to change the font or size of text at all.
我根本无法更改字体或文本大小。 Any help is very much appreciated!
很感谢任何形式的帮助!
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Apple SD Gothic NEO", size: 20)!]
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
A possible solution is replace the title label with a new one. 一种可能的解决方案是用新标签替换标题标签。
Example: 例:
let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 20, height: 50))
titleLabel.text = "Title"
titleLabel.font = UIFont.boldSystemFontOfSize(17)
self.navigationItem.titleView = titleLabel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.