最近在做一个复杂的后台返回多样式的文字。我想了想。直接和后台统一了一下数据的格式,然后使用NSAttributedString搞定了这个问题。以后就可以直接后台控制返回的样式了。其中用到的比较烦的是自宽。我统计了一下自宽的大小。可以参考一下下面的值
UIFontWeight | CGFloat |
---|---|
UIFontWeightUltraLight | -0.80000001192092896 |
UIFontWeightThin | -0.60000002384185791 |
UIFontWeightLight | -0.40000000596046448 |
UIFontWeightRegular | 0 |
UIFontWeightMedium | 0.23000000417232513 |
UIFontWeightSemibold | 0.30000001192092896 |
UIFontWeightBold | 0.40000000596046448 |
UIFontWeightHeavy | 0.56000000238418579 |
UIFontWeightBlack | 0.62000000476837158 |
由于CGFloat是一个Float值.不准确,所以我们可以理解为
UIFontWeight | CGFloat |
---|---|
UIFontWeightUltraLight | -0.8 |
UIFontWeightThin | -0.6 |
UIFontWeightLight | -0.4 |
UIFontWeightRegular | 0 |
UIFontWeightMedium | 0.23 |
UIFontWeightSemibold | 0.3 |
UIFontWeightBold | 0.4 |
UIFontWeightHeavy | 0.56 |
UIFontWeightBlack | 0.62 |