Not able to select custom fonts in Xcode 11 beta?

Viewed 684

How to add custom fonts in Xcode 11 beta(11M336w. Currently I am not able to select custom fonts. Its showing fonts are not installed.

enter image description here

1 Answers

xib and storyboard files are just simple, plain XML files. As with most XML files they're relatively easy to read. Setting a font for a UILabel or UITextField, is just as easy as adding an xml-attribute. In this case a <fontDescription>

In the Xcode navigator, navigate to the xib or storyboard file and choose "Open As->Source Code". In the example you can see a UITextField:

TextField without Font-Attribute

<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 with Font-Attribute

<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>

Save the file an open it again in IB and voilĂ !

Related