161

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

5 Answers 5

259

SF Symbols are similar to fonts, thus:

.font(.system(size: 60)) 
Sign up to request clarification or add additional context in comments.

4 Comments

Interesting. Very counter-intuitive since SF Symbols are used inside Image
Not really, especially when you think about web dev and font awesomes
The top answer should include the tip from @mathias-bak about being able to use .imageScale(Image.Scale).
It's counter-intuitive for people that don't need precision.
127

An alternative is to use .imageScale().

Image(systemName: "chevron.left").imageScale(.small) Image(systemName: "chevron.left").imageScale(.medium) Image(systemName: "chevron.left").imageScale(.large) 

1 Comment

These seems to be the recommended way to apply scaling. See developer.apple.com/videos/play/wwdc2020/10207
87

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

Comments

50

If you want to use frame you can as well:

Image(systemName: "plus") .resizable() .scaledToFit() .frame(width: 24, height: 24) 

2 Comments

This actually sets the exact size, unlike font approach. Good.
this is the way to force all symbols have the same size
8

Since iconographic SF Symbols are deeply integrated into the San Francisco system font (at the moment, we have 4000+ of them), they can be edited using vector graphics tools and can be manipulated habitual way.

var body: some View { Image(systemName: "swift").imageScale(.large) HStack { // Spacer() Label("Swift", systemImage: "swift").scaleEffect(2) // Spacer() Text("Swift \(Image(systemName: "swift"))").font(.largeTitle) // Spacer() } } 

enter image description here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.