SwiftUI: Cannot change background color of Segmented Control to clear?

1.1k Views Asked by At

I'm trying to change the background of a segmented control to clear but it isn't working. If I change it to a bright color like orange or blue, the color changes, but clear still leaves me with a shade of gray as a background color?

struct HomeSwipeView: View {
    
    init() {
        
        UISegmentedControl.appearance().backgroundColor = .clear
        UISegmentedControl.appearance().setTitleTextAttributes([
            .font : UIFont.preferredFont(forTextStyle: .headline)
        ], for: .normal)
        
    }
    
    var body: some View {
        Picker("", selection: $selectedTabIndex) {
            Text("One").tag(0)
            Text("Two").tag(1)
            
        }.pickerStyle(SegmentedPickerStyle())
    }
}
0

There are 0 best solutions below