How do I set the size of a SF Symbol in Xcode 11 using SwiftUI?
Asked
Active
Viewed 6.6k times
5 Answers
195
SF Symbols are similar to fonts, thus:
.font(.system(size: 60))

Ryan
- 10,798
- 11
- 46
- 60
-
27Interesting. Very counter-intuitive since SF Symbols are used inside `Image` – Zain Aug 05 '19 at 15:50
-
2Not really, especially when you think about web dev and font awesomes – Bartosz Nov 24 '19 at 03:07
-
7@Zain I agree with. Not just counter intuitive but weird – visc May 13 '20 at 17:29
-
2The top answer should include the tip from @mathias-bak about being able to use `.imageScale(Image.Scale)`. – richkzad Mar 19 '21 at 16:10
93
An alternative is to use .imageScale()
.
Image(systemName: "chevron.left").imageScale(.small)
Image(systemName: "chevron.left").imageScale(.medium)
Image(systemName: "chevron.left").imageScale(.large)

Mathias Bak
- 4,687
- 4
- 32
- 42
-
1These seems to be the recommended way to apply scaling. See https://developer.apple.com/videos/play/wwdc2020/10207/ – Ryan R Mar 21 '21 at 02:53
78
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))

YRUsoDiao
- 951
- 6
- 10
26
If you want to use frame you can as well:
Image(systemName: "plus")
.resizable()
.scaledToFit()
.frame(width: 24, height: 24)

Tob
- 627
- 6
- 9
3
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()
}
}

Andy Jazz
- 49,178
- 17
- 136
- 220