How do I set a weight to SF Symbols for iOS 13?
SwiftUI 1.0
I just wanted to also mention how to change the weight along with a custom font size.
HStack(spacing: 40) {
Image(systemName: "moon.zzz")
.font(Font.system(size: 60, weight: .ultraLight))
Image(systemName: "moon.zzz")
.font(Font.system(size: 60, weight: .light))
Image(systemName: "moon.zzz")
.font(Font.system(size: 60, weight: .regular))
Image(systemName: "moon.zzz")
.font(Font.system(size: 60, weight: .bold))
}
For UIKit, symbols can be configured as follows:
UIImage(systemName: "arrow.right",
withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .bold))
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))