2015-09-06 28 views
2

iOS 9中新的舊金山字體針對其使用的尺寸進行了優化,方法是調整SF Display和SF Text之間的跟蹤並動態切換。它在WWDC會議#指出804開發者不應該通過嘗試使用舊金山UIFont使用fontWithName來初始化,例如:在舊金山使用fontWithSize API

UIFont *originalFont = [UIFont systemFontOfSize:11]; 
UIFont *newFont = [UIFont fontWithName:originalFont.fontName size:44]; 

這是在使用,因爲系統無法優化字體爲新的大小fontWithName API。

相反,它被推薦到從原始字體UIFontDescriptor,並在新的大小創建一個新的字體,像這樣:

UIFont *originalFont = [UIFont systemFontOfSize:11]; 
UIFont *newFont = [UIFont fontWithDescriptor:originalFont.fontDescriptor size:44]; 

但是,如果以下允許優化他們沒有提到或不:

UIFont *originalFont = [UIFont systemFontOfSize:11]; 
UIFont *newFont = [originalFont fontWithSize:44]; 

我的問題是,它的fontWithSize API行爲類似於fontWithName API或fontWithDescriptor API - 它導致了新的大小與否優化的字體?

回答

4

我可以確認fontWithSize確實以新尺寸創建了優化字體。

Printing description of originalFont: 
<UICTFont: 0x7f8d9ba85340> font-family: ".SFUIText-Regular"; font-weight: normal; font-style: normal; font-size: 11.00pt 

Printing description of newFont: 
<UICTFont: 0x7f8d9ba7fe70> font-family: ".SFUIDisplay-Regular"; font-weight: normal; font-style: normal; font-size: 44.00pt 
相關問題