最近有这么一件糟心事儿,设计图总是比我写的看着舒服
仔细检查发现,设计图的字体,同样的字体,总是比我这边的要细,细的很明显
设计图 模拟器字体和设置,都和设计图保持一致了,但就是不一样!
这里大家看下,设计图中的代码模板,他是用
[UIFont fontWithName:@"PingFangSC-Regular" size:12];
去创建的字体,其实,系统字体就是PingFangSC-Regular,直接使用最普通的就是可以,But,就是不一样!
问题其实在这里:
虽然上面提示的是PingFangSC-Regular
,但是网页渲染的时候用的并不是PingFangSC-Regular
,而是HelveticaNeue,Helvetica,Arial,sans-serif
,这就是你和设计图的区别,如下图
下次设计师怼你的时候,记得怼回去!!!
如果你怼不回去,那么只能认命了,改吧
UIFont提供了这样一个方法[UIFont systemFontOfSize:12 weight:(UIFontWeightRegular)];
UIKIT_EXTERN const UIFontWeight UIFontWeightUltraLight API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightThin API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightLight API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightRegular API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightMedium API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightSemibold API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightBold API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightHeavy API_AVAILABLE(ios(8.2));
UIKIT_EXTERN const UIFontWeight UIFontWeightBlack API_AVAILABLE(ios(8.2));
这里面自上向下,一个比一个粗、重,对应设计图中的PingFangSC-Regular
,其实用UIFontWeightLight
更合适一些!可以使用这种方式让字体更像设计图
网友评论