【问题标题】:Not able to select custom fonts in Xcode 11 beta?无法在 Xcode 11 beta 中选择自定义字体?
【发布时间】:2019-06-15 06:03:38
【问题描述】:

如何在 Xcode 11 beta(11M336w) 中添加自定义字体。目前我无法选择自定义字体。未安装其显示字体。

【问题讨论】:

  • 小解决方法,选择“Attributed”更改字体细节并返回“Plain”

标签: ios swift custom-font xcode11 macos-catalina


【解决方案1】:

xib 和情节提要文件只是简单的纯 XML 文件。与大多数 XML 文件一样,它们相对容易阅读。为 UILabel 或 UITextField 设置字体就像添加 xml 属性一样简单。在这种情况下,<fontDescription>

在 Xcode 导航器中,导航到 xib 或 storyboard 文件并选择“Open As->Source Code”。在示例中,您可以看到一个 UITextField:

没有字体属性的TextField

<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Ihr Vorname" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="RLF-J9-mQz">
    <rect key="frame" x="215.66666666666663" y="16" width="231.33333333333337" height="14"/>
    <textInputTraits key="textInputTraits" autocapitalizationType="words"/>
</textField>

带有字体属性的文本字段

<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Ihr Vorname" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="RLF-J9-mQz">
    <rect key="frame" x="215.66666666666663" y="16" width="231.33333333333337" height="14"/>
    <fontDescription key="fontDescription" name="SourceSansPro-Light" family="Source Sans Pro" pointSize="17"/>
    <textInputTraits key="textInputTraits" autocapitalizationType="words"/>
</textField>

保存文件并在 IB 中再次打开它,瞧!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    • 2014-09-11
    相关资源
    最近更新 更多