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

标签 ios swift custom-font xcode11 macos-catalina

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

enter image description here

最佳答案

xib 和 Storyboard文件只是简单的纯 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

<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 中再次打开它,瞧瞧!

关于ios - 无法在 Xcode 11 beta 中选择自定义字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56607797/

相关文章:

ios - Storyboard segue 导致 AVAudioEngine 崩溃

objective-c - 播放iPod Library中的歌曲

swift - 如何在协议(protocol)扩展中设置委托(delegate)

ios - AdNetworkSupport 适配器 - AdColony 3 支持

css - 如何在 CSS 中使用下载的图像或字体(zip 文件)

iOS、 swift : How do I allow readers to use Navigation Bar Button Items to adjust body font size in a WKWebView?

ios - 如何检测在 iOS 上的 Firebase 测试实验室中运行的应用程序?

ios - 为什么 UITableViewCell 中的这些约束不明确?

ios - iOS 应用程序安装自定义 TrueType 字体的向后兼容性是否已被破坏?

ios - 使 UIView 大于其父 View