When working with the TabView component in Swift, you have the ability to enhance each tab with an icon using a system image. This can be achieved by using the systemImage
parameter within the Label
element.
Here is an example of how to use SF Symbols within a TabView:
TabView {
Text("First")
.tabItem {
Label("First", systemImage: "tray")
}
}
In this particular case, the icon “tray” is used.
But how can you discover other available icons to use in your app?
Apple has developed an application called SF Symbols, specifically designed for this purpose. You can download it from the following link: https://developer.apple.com/design/downloads/SF-Symbols.dmg. Once installed on your Mac, SF Symbols provides you with access to over 1500 symbols, each associated with a unique name.
To get started, open the SF Symbols app and you will be able to browse through the extensive collection of symbols, along with their corresponding names:
With SF Symbols, you can easily find the perfect icon to complement your app’s design. Happy symbol hunting!