È possibile specificare un carattere di sistema in un CSS
indirizzato a iOS (da visualizzare in un UIWebView
) e ottenere risultati simili come quando si progetta con Interface Builder:Lascia che iOS scelga il carattere di sistema Helvetica Neue o San Francisco nei CSS
Può un CSS
set sistema, System + Peso o Stili di testo invece di font-family:Helvetica Neue
:
<html>
<head>
<style type=\"text/css\">
body{font-family:Helvetica Neue; font-size:14;}
</style>
</head>
<body></body>
</html>
sistema
UIFont.systemFontOfSize(), UIFont.boldSystemFontOfSize(), UIFont.italicSystemFontOfSize()
System + Peso
Come in let mediumWeight = UIFont.systemFontOfSize(17, weight: UIFontWeightMedium)
UIFontWeightUltraLight, UIFontWeightThin, UIFontWeightLight, UIFontWeightRegular, UIFontWeightMedium, UIFontWeightSemibold, UIFontWeightBold, UIFontWeightHeavy, UIFontWeightBlack
Stili di testo
Body, Callout, Caption 1, Caption 2, Footnote, Headline, Subhead, Title 1, Title 2, Title 3
Ho provato a impostare 'font-family' su' -apple-system' ma su iOS 8.4.1 (iPhone 5s) non funziona e il testo viene visualizzato in Times New Roman. L'impostazione della proprietà 'font' funziona correttamente. –
Usa 'font-family: '-apple-system', 'HelveticaNeue';'. Selezionando 'Helvetica' quando' -apple-system' non è definito e 'San Francisco' su iOS 9. – SwiftArchitect
@SwiftArchitect, grazie. Funziona perfettamente per la mia app. –