美文网首页iOS猛码计划
iOS开发中调整字体的粗细

iOS开发中调整字体的粗细

作者: Michael_NO1 | 来源:发表于2017-08-01 17:45 被阅读12次
调整字体的粗细可以通过设置字重来实现
UIFount中有一个类方法:
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize weight:(CGFloat)weight NS_AVAILABLE_IOS(8_2);
通过该方法设置字号及自重, weight即为自重参数;
在UIFontDescriptor类中有自重参数;
自上向下, 依次加粗, 具体可以自己调试选择:
UIKIT_EXTERN const CGFloat UIFontWeightUltraLight NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightThin NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightLight NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightRegular NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightMedium NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightSemibold NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightBold NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightHeavy NS_AVAILABLE_IOS(8_2);
UIKIT_EXTERN const CGFloat UIFontWeightBlack NS_AVAILABLE_IOS(8_2);

举个栗子:
[UIFont systemFontOfSize:20 weight:UIFontWeightLight]

相关文章

网友评论

    本文标题:iOS开发中调整字体的粗细

    本文链接:https://www.haomeiwen.com/subject/eitslxtx.html