Hello
I made a custom Picker View but I don't have any idea on how to change the background color to grey when I press on one of the options
Here is the code:
Thank you for your time
I made a custom Picker View but I don't have any idea on how to change the background color to grey when I press on one of the options
Here is the code:
Code Block struct PickerView: View { var arr: [String] = ["Easy", "Medium", "Hard"] var h: CGFloat = 50 var w: CGFloat = 320 @ObservedObject var input: UserInput var body: some View{ HStack(spacing: 40){ ForEach(0..<arr.count){ i in HStack(spacing: 25){ Text(arr[i]) .bold() .onTapGesture { switch i{ case i: input.indi = i default: return } print(i) } if(i < arr.count - 1){ Divider() .frame(height: 25) } } } }.padding() .clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous)) .overlay( RoundedRectangle(cornerRadius: 16) .stroke(Color.gray, lineWidth: 3) ) } } class UserInput: ObservableObject { @Published var indi: Int = 0 }
Thank you for your time