无法在 Xcode 11 beta 中选择自定义字体?

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

enter image description here


小的解决办法,选择“属性”,更改字体规范,然后切换回“普通”。 - Floris497
1个回答

0

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

在Xcode导航器中,导航到xib或storyboard文件,选择“打开方式->源代码”。在示例中,您可以看到一个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中重新打开,就这样!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接