ios 如何使用 Pixate 框架定义我的 CSS 以显示“HelveticaNeue-Light”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21644663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I define my CSS to display 'HelveticaNeue-Light' using Pixate Framework?
提问by bobmoff
Clearification! This question is about the iOS framework Pixate (http://www.pixate.com), and not regular CSS inside of a UIWebView.
澄清!这个问题是关于 iOS 框架 Pixate ( http://www.pixate.com),而不是 UIWebView 中的常规 CSS。
Code in default.css :
default.css 中的代码:
.title {
font-family: 'Helvetica Neue';
font-weight: light;
font-size: 30px;
color: #005284;
}
}
Code in view:
代码视图:
UILabel *label = [UILabel new];
label.styleClass = @"title";
Result when logging:
记录时的结果:
<UICTFont: 0x10d09e210> font-family: "HelveticaNeue-UltraLight"; font-weight: normal; font-style: normal; font-size: 30.00pt
When I try font-weight: medium;
I get HelveticaNeue-Medium
When I try font-weight: 300;
I get HelveticaNeue-UltraLight
When I try font-weight: 400;
I get Helvetica Neue
When I try font-family: 'HelveticaNeue-Light';
I get .HelveticaNeueInterface-M3
??? (I guess this is the default system font)
当我尝试时font-weight: medium;
我得到HelveticaNeue-Medium
当我尝试时font-weight: 300;
我得到HelveticaNeue-UltraLight
当我尝试时font-weight: 400;
我得到Helvetica Neue
当我尝试时font-family: 'HelveticaNeue-Light';
我得到.HelveticaNeueInterface-M3
??? (我猜这是默认的系统字体)
If I set the font through code with
如果我通过代码设置字体
label.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:30];
It looks as it should, (and the log says HelveticaNeue-Light
)
它看起来应该,(和日志说HelveticaNeue-Light
)
Here a screenshot. The one of the left is when using code, and the one on the right is when using Pixate with `font-family: 'HelveticaNeue-Light'
这里有一个截图。左边一个是使用代码时,右边一个是使用带有`font-family: 'HelveticaNeue-Light'的Pixate时
How do I get 'HelveticaNeue-Light' (like the one on the left in the screenshot above) using Pixate CSS ?
如何使用 Pixate CSS 获得“HelveticaNeue-Light”(如上图左侧的那个)?
采纳答案by pixatepaul
You found a bug in Pixate and it has been fixed for Pixate Framework 2.1.
您在 Pixate 中发现了一个错误,它已在 Pixate Framework 2.1 中得到修复。
回答by Maciej Swic
This works on Mavericks and my iOS 7 simulator. Don't know about others.
这适用于 Mavericks 和我的 iOS 7 模拟器。不知道别人怎么样。
.title {
font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
font-size: 30px;
color: #005284;
}
Here is my test code:
这是我的测试代码:
<html>
<head>
<style>
.first {
font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
font-size: 30px;
color: #005284;
}
.second {
font-family: 'Helvetica';
font-size: 30px;
color: #005284;
}
</style>
</head>
<div class="first">Hello, World!</div>
<div class="second">Hello, World!</div>
</html>
And the result in Safari http://s.swic.name/TpEP
结果在 Safari http://s.swic.name/TpEP