使用下述方法設(shè)置UIFont:
UIFont *font = [UIFont systemFontOfSize:18 weight:UIFontWeightLight];
這個(gè)方法是 iOS8.2 之后出來(lái)的芭概,但是 iOS8.0 上也能運(yùn)行這個(gè)方法赛不,只不過(guò)在 8.2 時(shí)才將這個(gè)方法變?yōu)楣灿蠥PI。
參數(shù) size 是字體大小罢洲,參數(shù) weight 是UIFontWeight(粗細(xì))踢故。
UIFontWeight的值:從上到下依次加粗
// Suggested values for use with UIFontWeightTrait, and UIFont's systemFontOfSize:weight:
// Beware that most fonts will _not_ have variants available in all these weights!
UIKIT_EXTERN const UIFontWeight UIFontWeightUltraLight // 超細(xì)字體
UIKIT_EXTERN const UIFontWeight UIFontWeightThin // 纖細(xì)字體
UIKIT_EXTERN const UIFontWeight UIFontWeightLight // 輕量字體
UIKIT_EXTERN const UIFontWeight UIFontWeightRegular // 常規(guī)字體
UIKIT_EXTERN const UIFontWeight UIFontWeightMedium // 中等字體
UIKIT_EXTERN const UIFontWeight UIFontWeightSemibold // 半粗字體
UIKIT_EXTERN const UIFontWeight UIFontWeightBold // 加粗字體
UIKIT_EXTERN const UIFontWeight UIFontWeightHeavy // 重粗字體
UIKIT_EXTERN const UIFontWeight UIFontWeightBlack // 最粗字體
在size=18時(shí),設(shè)置不同weight的效果對(duì)比: