本文介绍了如何在iOS 9中使用新旧金山字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 9 之前引用我们使用 fontWithName UIFont 的字体:

  [UIFont fontWithName:@HelveticaNeuesize:18] 

现在我们要转到iOS 9.如何以同样的方式引用新的旧金山字体



我们可以将它与 systemFontOfSize UIFont 结合使用,但是如何引用除常规?例如,如何使用 San Francisco Medium San Francisco Light 字体?

解决方案

  let font = UIFont.systemFontOfSize(18 )

You can 可以直接使用字体名称,但是不能认为这是安全的:

  let font = UIFont(name:.SFUIText-Medium,size:18)! 

您也可以使用,如下所示:

  let font = UIFont.systemFontOfSize(18,weight:UIFontWeightMedium)



$ p
$ b $ pre $ let $ font size = UIFont.systemFontOfSize(18,weight:UIFontWeightLight)


Before iOS 9 to reference fonts we used fontWithName of UIFont:

[UIFont fontWithName:@"HelveticaNeue" size:18]

Now we're moving to iOS 9. How to reference a new San Francisco font in the same way?

We can use it with systemFontOfSize of UIFont, but how to reference styles other than regular? For example, how to use San Francisco Medium or San Francisco Light fonts?

解决方案

In iOS 9 it is the system font, so you could do:

let font = UIFont.systemFontOfSize(18)

You can use the font name directly, but I don't think this is safe:

let font = UIFont(name: ".SFUIText-Medium", size: 18)!

You can also create the font with specific weight, like so:

let font = UIFont.systemFontOfSize(18, weight: UIFontWeightMedium)

or

let font = UIFont.systemFontOfSize(18, weight: UIFontWeightLight)

这篇关于如何在iOS 9中使用新旧金山字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:42