ios - 如何在 Swift 4/Xcode 10.1 的整个应用程序中使用自定义字体?
<p><div>
<aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
<div class="d-flex fd-column fw-nowrap">
<div class="d-flex fw-nowrap">
<div class="flex--item wmn0 fl1 lh-lg">
<div class="flex--item fl1 lh-lg">
<b>这个问题在这里已经有了答案</b>:
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>你可以使用 UIFont 的扩展来做</p>
<pre><code>extension UIFont {
public enum FontWeight {
//cases are just font family like bold, light, italic
case .light
}
func appFont(weight : FontWeight, size : CGFloat) -> UIFont {
var fontName = "Times New Roman-"
switch weight {
case .light {
fontName = fontName + "light" // add your family name here
}
}
return UIFont(name: fontName, size: size)!
}
}
</code></pre>
<p>如果是标签</p>
<pre><code>label.font = UIFont.appFont(weight : .light, size : 17)
</code></pre></p>
<p style="font-size: 20px;">关于ios - 如何在 Swift 4/Xcode 10.1 的整个应用程序中使用自定义字体?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/54643860/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/54643860/
</a>
</p>
页:
[1]