如何添加样式?

时间:2015-06-18 19:29:51

标签: ios swift

如何在字体中添加样式?

golabel.font = UIFont(name: "Apple SD Gothic Neo" , size: 40)

我已经尝试了

golabel.font = UIFont(name: "Apple SD Gothic Neo-Thin" , size: 40)

但它只是直接使用大小为17的系统字体。

2 个答案:

答案 0 :(得分:1)

您表示错误的字体名称。使用此列表中的字符串:

https://support.apple.com/en-us/HT202771

答案 1 :(得分:1)

您应该代表以下字体名称:

  

golabel.font = UIFont(名称:“AppleSDGothicNeo-Thin”,大小:40)

您可以获得家庭的字体名称(本例中为'Apple SD Gothic Neo'):

  

UIFont.fontNamesForFamilyName(“Apple SD Gothic Neo”)

例如,打印时,您会看到:

  

[AppleSDGothicNeo-Bold,AppleSDGothicNeo-Thin,   AppleSDGothicNeo-UltraLight,AppleSDGothicNeo-Regular,   AppleSDGothicNeo-Light,AppleSDGothicNeo-Medium,   AppleSDGothicNeo-SemiBold]