SwiftUI Label : Label with Asset Image

Label supports not only SF symbols but it also supports image from Assets catalog. I have DevTechie logo in my Assets so I will use that in my label.

Label("DevTechie", image: "dt")


But there is an issue here(did you notice 😄). Our image is rendered with its original size.

Label doesn’t resize images so if you need to display image next to title, you will have to take matters in your hand. You have two choices:

Resize image inside ViewBuilder overload of init:

Label {
    Text("DevTechie")
        .font(.largeTitle.lowercaseSmallCaps())
} icon: {
    Image("dt")
        .resizable()
        .frame(width: 40, height: 40)
        .clipShape(Circle())
}



Or change size in Asset catalog and use it directly.