deskside / emodiary

0 stars 0 forks source link

SF symbol #14

Closed deskside closed 1 year ago

deskside commented 1 year ago

To render multicolor sf symbol:

Image(systemName: "externaldrive.badge.plus")
    .symbolRenderingMode(.multicolor)

Reference: 史上最全的SF Symbols 使用指南

deskside commented 1 year ago

In SwiftUI you can render a palette image by using the .palette rendering mode followed by a foreground style containing one, two, or three colors:

Image(systemName: "person.3.sequence.fill")
    .symbolRenderingMode(.palette)
    .foregroundStyle(.red, .green, .blue)
deskside commented 1 year ago

Show different SF symbol by tapping the button.

@State private var showingAlerts = true

Toggle(isOn: $showingAlerts) {
                        Label("Show Alerts", systemImage: "bell")
                            .symbolVariant(showingAlerts ? .none : .slash)
                    }
                    .toggleStyle(.button)
deskside commented 1 year ago

It turns out that swiftUI comes with a Lable consisting of a SF symbol with a title.

Label("Lightning", systemImage: "bolt.fill")