swift bold title in navigation bar

时间:2018-12-04 18:28:54

标签: swift

installed fonts for title navigation bar

UINavigationBar.appearance().titleTextAttributes = [.font: UIFont(name: "OpenSans", size:50 )!,NSAttributedString.Key.foregroundColor : UIColor.purple]

how do I make it bold ?

found, that can be done so, but after all the fine print I already set

.font : UIFont.boldSystemFont(ofSize: 50)

2 个答案:

答案 0 :(得分:1)

您必须说要使用的字体命名为 OpenSans ,其样式为粗体

"OpenSans-Bold"

所以使用这个:

.font: UIFont(name: "OpenSans-Bold", size: 50)!

答案 1 :(得分:1)

您应该使用Open Sans的粗体。代替“ OpenSans”,使用与粗体版本ex对应的字​​符串。 “ OpenSans-Bold”

UINavigationBar.appearance().titleTextAttributes = [.font: UIFont(name: "OpenSans-Bold", size:50 )!,NSAttributedString.Key.foregroundColor : UIColor.purple]

字体名称将特定于您的环境。