Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the size of a SF Symbol in SwiftUI?

How do I set the size of a SF Symbol in Xcode 11 using SwiftUI?

like image 517
Ryan Avatar asked Aug 03 '19 21:08

Ryan


People also ask

How do I change the size of my SF symbol?

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.

How do I use the SF symbol in SwiftUI?

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.

How do I change the SF color in SwiftUI?

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) .


2 Answers

SF Symbols are similar to fonts, thus:

.font(.system(size: 60)) 
like image 108
Ryan Avatar answered Sep 17 '22 07:09

Ryan


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)) 
like image 30
YRUsoDiao Avatar answered Sep 21 '22 07:09

YRUsoDiao