How do I set the size of a SF Symbol in Xcode 11 using SwiftUI?
To change the scale of an SF Symbol you can make use of a UIImage Symbol Configuration. It allows you to set the font, scale, point size, weight, and text style.
SwiftUI uses the systemName parameter for SF Symbol lookup. Keep in mind that you can use string interpolation to show an SF Symbol as the part of any text. Another SwiftUI view that plays well with SF Symbols is Label. The Label view contains both text and an image and shows them according to the current context.
If you use SF Symbols in SwiftUI's Image view, you can get simple colors using the foregroundColor() attribute, or enable their multicolor variants by using . renderingMode(. original) .
SF Symbols are similar to fonts, thus:
.font(.system(size: 60))
You can set weights and sizes:
Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .ultraLight)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .thin)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .light)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .regular)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .medium)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .semibold)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .bold)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .heavy)) Image(systemName: "checkmark.circle") .font(.system(size: 16, weight: .black))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With