Snippets
SwiftUI Image Resizing and SF Symbols
Resize bitmap images and SF Symbols predictably by separating intrinsic image behavior, content mode, and symbol styling.
4 min readUpdated 2026-06
import SwiftUI
struct ProfileImageRow: View {
var body: some View {
HStack(spacing: 12) {
Image("avatar")
.resizable()
.scaledToFill()
.frame(width: 56, height: 56)
.clipShape(Circle())
Label("Available", systemImage: "checkmark.seal.fill")
.font(.headline)
.imageScale(.medium)
.foregroundStyle(.green)
}
}
}Implementation notes
Use resizable before scaledToFit or scaledToFill, otherwise the image keeps its intrinsic dimensions.
scaledToFill crops when the aspect ratio differs, so pair it with a frame and clipping shape.
For symbols beside text, font and imageScale usually produce a more native result than a fixed frame.
Checklist
Choose fit when content preservation matters and fill when a stable crop matters.
Add an accessibility label when the image communicates meaning.
Preview with long adjacent text so symbol rows do not compress awkwardly.
Related reference
SwiftUI Image Rendering Mode and Interpolation
Control whether images keep original colors, act as templates, scale smoothly, or stay crisp for pixel-style art.
SwiftUI clipShape, mask, and contentShape
Clipping controls what is visible, masking controls alpha, and contentShape controls where interaction happens.
SwiftUI foregroundStyle and tint
Prefer foregroundStyle and tint for modern SwiftUI color styling, especially when controls, symbols, gradients, and semantic materials mix.