Swi*_*ect 24 css fonts uiwebview ios
是否可以在CSS目标iOS中指定系统字体(在a 中显示UIWebView),并获得与使用Interface Builder进行设计时类似的结果:
可以CSS设置系统,系统+重量或文本样式而不是font-family:Helvetica Neue:
<html>
<head>
<style type=\"text/css\">
body{font-family:Helvetica Neue; font-size:14;}
</style>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
系统
UIFont.systemFontOfSize(), UIFont.boldSystemFontOfSize(), UIFont.italicSystemFontOfSize()
Run Code Online (Sandbox Code Playgroud)
系统+重量
如在 let mediumWeight = UIFont.systemFontOfSize(17, weight: UIFontWeightMedium)
UIFontWeightUltraLight, UIFontWeightThin, UIFontWeightLight, UIFontWeightRegular, UIFontWeightMedium, UIFontWeightSemibold, UIFontWeightBold, UIFontWeightHeavy, UIFontWeightBlack
Run Code Online (Sandbox Code Playgroud)
文字样式
Body, Callout, Caption 1, Caption 2, Footnote, Headline, Subhead, Title 1, Title 2, Title 3
Run Code Online (Sandbox Code Playgroud)
Swi*_*ect 64
在iOS和OS X上使用"font-family"CSS属性的"-apple-system"CSS值.
正如webkit.org上所述,目前在w3c中有关于标准化该值的讨论,因此作者可以简单地指定系统.
iOS 9和Safari OS X 10.11上的-apple-system
使用font-family: CSS属性:
font-family: -apple-system;
font-family: '-apple-system','HelveticaNeue'; // iOS 8 compatible, credit: @MarcoBoschi
Run Code Online (Sandbox Code Playgroud)
在上下文中(回退到HelveticaNeue时-apple-system未定义):
<html>
<head>
<style type=\"text/css\">
body{font-family: '-apple-system','HelveticaNeue'; font-size:17;}
</style>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
使用font-weight: CSS属性:
normal, bold, bolder, lighter
100, 200, 300, 400, 500, 600, 700, 800, 900
Run Code Online (Sandbox Code Playgroud)
使用font-style: CSS属性:
normal, italic
Run Code Online (Sandbox Code Playgroud)
iOS 8.4上的-apple-system-xxx.
使用font: CSS属性(代表整个样式,包括大小和重量):
font: -apple-system-body
font: -apple-system-headline
font: -apple-system-subheadline
font: -apple-system-caption1
font: -apple-system-caption2
font: -apple-system-footnote
font: -apple-system-short-body
font: -apple-system-short-headline
font: -apple-system-short-subheadline
font: -apple-system-short-caption1
font: -apple-system-short-footnote
font: -apple-system-tall-body
Run Code Online (Sandbox Code Playgroud)
在上下文中:
<html>
<head>
<style type=\"text/css\">
body{font: -apple-system-body;}
</style>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)
►在GitHub上找到此解决方案以及有关Swift Recipes的其他详细信息.
| 归档时间: |
|
| 查看次数: |
16782 次 |
| 最近记录: |