UILabel设置字重
在 Objective-C 中设置 UILabel
的字重(Font Weight),有以下几种常见方式,主要依赖于 UIFont
的 systemFontOfSize:weight:
方法(iOS 8.2+ 可用)。
使用系统字体设置字重(推荐)
label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
常用 UIFontWeight
枚举值:
权重名称 | 值(CGFloat) | 显示效果 |
---|---|---|
UIFontWeightUltraLight | -0.8 | 极细 |
UIFontWeightThin | -0.6 | 很细 |
UIFontWeightLight | -0.4 | 偏细 |
UIFontWeightRegular | 0.0 | 常规 |
UIFontWeightMedium | 0.23 | 中等 |
UIFontWeightSemibold | 0.3 | 偏粗 |
UIFontWeightBold | 0.4 | 粗体 |
UIFontWeightHeavy | 0.56 | 更粗 |
UIFontWeightBlack | 0.62 | 最粗 |