Skip to content
Join us for Free for Full Access to site Content

SwiftUI Label

SwiftUI Label is a view that represents a combination of an icon and a label.

Label is a popular idiom that can be used in collections, lists, menus of action items, and disclosable lists

To create a Label in SwiftUI you need to provide a title and the name of an image. An Image can be an icon from the SF Symbols collection or your image from the Assets.

How to create a SwiftUI Label

struct LabelView: View {
    var body: some View {
        
        Label("I am a Label", systemImage: "flame")
        
    }
}

Creating a title-only Label

This can be useful if you want to show a title-only Label. For example when you rotate the device.

 Label("Title Only Label", systemImage: "flame")
            .labelStyle(TitleOnlyLabelStyle())

How to create an icon-only Label

 Label("Icon-Only Label", systemImage: "flame")
            .labelStyle(IconOnlyLabelStyle())

Label With Image from the Assets Catalog

Put the image (in our case swiftui-image.png ) in your assets catalog and use it inside the Label initialization.

Label("Image Label", image: "swiftui-image")

How to scale Label in SwiftUI

Label("Scaled Label", systemImage: "flame")
.font(.title)

Create a complex label with custom SwiftUI Views

This content is for members only. Login or Register to read

Label Documentation

Learn more about SwiftUI using SwiftUI Tutorials by the AppMakers.

 

 

Back To Top
Search

Get Latest App Development News, Tips and Tutorials

* indicates required


Send this to a friend