Changes

Working with Fonts and Attributed Strings in watchOS 2

670 bytes added, 20:33, 23 October 2015
no edit summary
== Dynamic Text and Text Style Fonts ==
Apple Watch users are able to specify a preferred text size which WatchKit apps are expected to adopt when displaying text (also referred to as the preferred content size). The current text size can be configured via the Apple Watch app on the paired iPhone device. To access this setting, launch the Apple Watch app, select the My Watch tab followed by the Brightness & Text Size option. As shown in Figure 20 -1, options are provided on this screen to adjust the font size and use bold text.
Almost without exception, the built-in WatchKit apps adopt the font size setting selected by the user when displaying text. Apple also recommends that third-party apps conform to the user’s text size selection wherever possible. WatchKit specifies a variety of different preferred text styles for this purpose including headings, sub-headings, body, captions and footnotes. The text style used by an interface object in a scene can be configured either using Interface Builder or in code.
[[Image:apple_watch_text_size.png]]
Figure 20 -1
[[Image:watchkit_select_text_style.png]]
Figure 20-2
[[Image:watchkit_headline_text_style.png]]
Figure 20-3
[[Image:watchkit_system_font_selection.png]]
Figure 20-4
[[Image:watchkit_set_system_font_size.png]]
Figure 20-5
When using fonts in WatchKit app code, it is necessary to use attributed strings to incorporate the font in the text string being displayed. The use of mutable attributed strings allows multiple attributes such as fonts and colors to be included in a single string.
 
 
<google>BUY_WATCHOS2</google>
 
 
<hr>
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="20%">[[A watchOS 2 WatchKit Dynamic Layout and Animation Tutorial|Previous]]<td align="center">[[watchOS 2 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[A watchOS 2 App Custom Font Tutorial|Next]]</td>
<tr>
<td width="20%">A watchOS 2 WatchKit Dynamic Layout and Animation Tutorial<td align="center"><td width="20%" align="right">A watchOS 2 App Custom Font Tutorial</td>
</table>