SF Symbols in iOS 13

craiggrummitt
Jun 7 · 4 min read

I was playing around with the amazing SwiftUI with Apple’s tutorials (stay tuned, I hope to write something on SwiftUI soon) when I noticed something interesting:

Where does this “star.fill” come from, I wondered… There’s no “star.fill” in the asset catalog?! It turns out the clue was in the initializer parameter “systemName”.

So from iOS 13, UIImage can now be initialized with systemName, which generates a “system symbol image”. What are these “system symbol images”? Well, Apple has provided a program called “SF Symbols” that lets you browse all 1,500+ of them! You can download the program at their Apple Design Resources page.

Here are just some of the SF Symbols!

And it couldn’t be easier to use:

Generate a UIImage from an SF symbol

There is a WWDC session on SF symbols well worth checking out here. You’ll also find Apple’s guidelines for using SF Symbols in the Human Interface Guidelines here. You’ll also find guidance there for building your own SF Symbol, using the SF Symbols program.

In the SF Symbols program you’ll notice you can play with the weight and scale of the image. You’ll find an example of these in the Human Interface Guidelines:

You can adjust the weight and scale of the image, along with its pointSize, using a config property:

It should be noted that pointSize refers to a typographical point size — the same point size a font uses — rather than points on the screen.

Why have both pointSize and scale, you might ask. Well, the scale property allows you to adjust the scale of a symbol in relation to the text around it without having to adjust the pointSize. Perhaps you might be lining up an image with a label, adding an image to a button, or even inserting an SF symbol in a string! (It should be mentioned that inserting an SF symbol into a string isn't working yet for the current beta of Xcode 11, but it sounds very promising, even adjusting the style of the symbol to the text surrounding it!)

Having point size available is great, but we generally try to avoid specifying a point size with text — instead we prefer to use text styles, such as Body, Headline, etc where possible to take advantage of dynamic type. This is possible with SF symbols too — instead of specifying the point size, you can create the config property using a text style, just as you might with a label or text field:

By the way, so far we’ve been looking at how to add SF symbols in code. We also saw at the start of this post that you can also include SF symbols in SwiftUI views.You might be interested to know you can also add them in the storyboard:

Well, that’s the basics — there’s a lot more to look at — such as alignment, automatic configuration based on size class, making your app with SF symbols compatible with devices with < iOS 13, and building your own SF symbols. Again, I recommend you check out the WWDC session on SF symbols here.

In conclusion I think this is a really welcome addition to Xcode/iOS — apps will have a more consistent look across iOS, and I think SF symbols should make life much easier for us — less time for example, taken up sourcing icons and finding (or designing) a variety of sizes and weights. What do you think?

craiggrummitt

Written by

Founder of http://interactivecoconut.com, book iOS Dev in Swift https://www.manning.com/books/ios-development-with-swift