How Can I Apply Custom Fonts in My Apple Watch App?
Apple watch custom font by Apple Watch apps with desired Fonts might be the next innovative thing you want to do. Who doesn’t like to do changes with technology especially when you have the latest Apple Watch! Unfortunately Xcode offers very few types of Fonts to create Apple Watch apps. And if users want to try some new Fonts, they will have to add them manually to project. This can be done by changing Font through code. This blog will elaborate entire procedure to perform this change in project.
Steps for Changing Font
It is important to have the .otf file for apple watch custom font. Here we will use KaushanScript font.
Now, open the Xcode project to which you want to add font. Right-click on WatchKit Extension and select Add Files to option.
Select new font and check the option of “Copy Items If Needed”. Also check the demo WatchKit extension and demo WatchKit App options before you import this new Font to project.
Now select Project Name>> WatchKit Extension>> Build Phases >> Copy Bundle Resources making sure that bundle includes the Font.
Now add the Fonts provided by application entry to plist file belonging to both WatchKit Extension and WatchKit App. For Item 0, set it to name of font file you want to ass with extension.
To set font afterwards, actual font name is required. The actual font name can be fetched from InterfaceController.swift file of initial view which comes under WatchKit extension and call printFonts method in awakeWithContext.
Now Launch Watch app and in debug area find the font name. As soon as you get the name, you can remove the printFonts method from swift file.
Switch to initial view of watch app and add a label to it. Now, connect it to the code using IBOutlet.
Now create NSAttributedString instance with parameters as shown in image and then call setAttributedText (attributedText) to finally change the apple watch font Choose the Font name and size carefully.
When you will launch the App again, new Font will be visible.
In order to accommodate the procedure one must be aware with different coding set with Xcode. It is undoubtedly a radical way of designing your Apple apps with completely new design. But it is important to perform the whole setting carefully. A customized desired Font for your Apple watch can immediately enhance your watch and can give it a complete new look.