Sitemap
DevTechie

DevTechie.com is all about sharing knowledge by practical means. We focus on solving real world challenges via code.

SwiftUI Image: a closer look

13 min readNov 16, 2021

--

There is a famous saying “A picture is worth a thousand words” 😎 so we are gonna learn about Image views in SwiftUI.

We can use Image view to display images inside our app. In its simplest form Image View can be initialized with

Image("image name")

or

Image(systemName: "SF symbol name")

Asset Image

Image(“dt”) initializer can load and display an image that is part of app bundle or inside Assets catalog folder. This initializer takes name of image as the parameter. Assets catalog supports both bitmap and PDF based vectors and Image view is capable of rendering both types without any issue.

struct ImageExample: View {
var body: some View {
Image("dt") // dt is name of image in Assets
}
}

System Image

Image(systemName: “person.circle”) initializer accepts string name for SF symbol.

struct ImageExample: View {
var body: some View {
Image(systemName: "person.circle")
.font(.system(size: 100))
}
}

As you can see in the code above, with SF symbol initializer, you can apply font size.

--

--

DevTechie
DevTechie

Published in DevTechie

DevTechie.com is all about sharing knowledge by practical means. We focus on solving real world challenges via code.

Responses (2)