Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set a weight to SF Symbols for iOS 13?

I have this

Image(systemName: "arrow.right")

But how do I make it bold, semibold etc?

I am using the new SwiftUI.

like image 662
Just a coder Avatar asked Jun 09 '19 22:06

Just a coder


People also ask

What is SF symbol?

SF Symbols 4 With over 4,000 symbols, SF Symbols is a library of iconography designed to integrate seamlessly with San Francisco, the system font for Apple platforms. Symbols come in nine weights and three scales, and automatically align with text labels.


2 Answers

When using the font modifier, set a weight to the font you're passing.

For example, if you want to use one of the default text styles (which I recommend, since they adapt to the user's Dynamic Type setting), you can do it like this:

Image(systemName: "arrow.right")
  .font(Font.title.weight(.ultraLight))

If you want to specify a font size, you can do it like this:

Image(systemName: "arrow.right")
  .font(Font.system(size: 60, weight: .ultraLight))
like image 181
EmilioPelaez Avatar answered Oct 19 '22 04:10

EmilioPelaez


For UIKit, symbols can be configured as follows:

UIImage(systemName: "arrow.right",
        withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .bold))
like image 75
Hejazi Avatar answered Oct 19 '22 03:10

Hejazi