Last updated 2 years ago
โฉ โฉ
Sarun โฉ
Paul โฉ
Simple Swfit Guide โฉ
โญ๏ธ
FIVE STARS โฉ - with custom LabelStyle โญ๏ธ
โฉ โฉ โฉ
(protocol)
uses .
used by as tab labels.
struct Label<Title: View, Icon: View>
struct ContentView: View { // view body var body: some View { VStack { favLabel bondLabel weatherLabels } } // favorites label var favLabel: some View { Label { Text("Favorites") .bold() .foregroundColor(.green) // โญ๏ธ title color } icon: { Image(systemName: "heart") .symbolVariant(.fill) .foregroundColor(.pink) // โญ๏ธ icon color } } // james bond label var bondLabel: some View { Label { // โญ๏ธ multiple texts Text("James Bond") .font(.body) .foregroundColor(.primary) Text("Mr.") .font(.subheadline) .foregroundColor(.secondary) } icon: { // โญ๏ธ custom icon Circle() .fill(Color.orange) .frame(width: 44, height: 44, alignment: .center) .overlay(Text("JB")) } } var weatherLabels: some View { HStack { Label("Rain", systemImage: "cloud.rain") .foregroundColor(.cyan) Label("Snow", systemImage: "snow") Label("Sun", systemImage: "sun.max") .foregroundColor(.yellow) } .labelStyle(.iconOnly) // โญ๏ธ icon only } }