I would like to use SF Symbols in a SegmentedControl in SwiftUI. Copy this code into a project and watch what happens. There is no good way to explain the behavior. You have to see it for yourself.
import SwiftUI
struct ContentView : View {
@State private var favoriteColor = 0
var body: some View {
VStack {
SegmentedControl(selection: $favoriteColor) {
Image(systemName: "hammer.fill").tag(0)
Image(systemName: "house.fill").tag(1)
Image(systemName: "desktopcomputer").tag(2)
Image(systemName: "cart.fill").tag(3)
Image(systemName: "phone.arrow.right.fill").tag(4)
Image(systemName: "wand.and.rays").tag(5)
Image(systemName: "slider.horizontal.3").tag(6)
}
Text("Value: \(favoriteColor)")
}
}
}
#if DEBUG
struct ContentView_Previews : PreviewProvider {
static var previews: some View {
ContentView()
}
}
#endif
If anyone figures this out please provide an answer or an explanation.