In iOS 7, when navigating back using the new swipe-from-edge-of-screen gesture, the title of the Back button ("Artists") fades from being pink (in the example below) and having regular font weight to being black and having bold font weight.
It seems to me that the animation uses two different labels in order to achieve this effect; one fading out as the other fades in. However, Apple has somehow adjusted the font so that the regular label perfectly overlays the bold one, thus creating the illusion of a single label morphing between two different weights and colors.
Have they simply adjusted the letter spacing on the regular font so that it matches onto the bold one? In that case, how would that be achieved in iOS 7? Does Text Kit have any awesome features for doing this or how should I go about it?
For Swift 4+ the syntax is as simple as:
You can adjust letter spacing like this, using
NSAttributedString
.In Objective-C:
In Swift:
More info on kerning is available in Typographical Concepts from the Text Programming Guide.
I don't think there's a TextKit feature that will automatically match font spacing between bold and regular text.
With Swift 4 and iOS 11,
NSAttributedStringKey
has a static property calledkern
.kern
has the following declaration:The following Playground code shows a possible implementation of
kern
in order to have some letter spacing in yourNSAttributedString
: