Scrolling to the selected item in Picker selection list of SwiftUI

Viewed 110

I have following picker. The problem is the list Picker shows is scrollable and when selected value is near the end of the array user have to scroll manually. Is there a way to scroll to selected item automatically with a setting.

                        Menu {
                            Picker("", selection: $selectedItem) {
                                ForEach(0..<myArray.count, id: \.self) {index in
                                    Text(myArray[index])
                                }  
                            }
                        } label: {
                            HStack(spacing: 1) {
                                Text("Selection Name")
                                    .foregroundColor(.white)
                                    .frame(width: myWidth, height: myHeight, alignment: .trailing)
                                Text(myArray[$selectionIndex])
                                .frame(width: myWidth, height: myHeight, alignment: .center)
                                .multilineTextAlignment(.leading)
                                .background(Color.white)
                                .foregroundColor(.black)
                                .cornerRadius(5)
                                Text(myAffix)
                                    .foregroundColor(.white)
                                    .frame(width: myWidth, height: myHeight, alignment: .leading)
                                
                            }
                            .foregroundColor(.white)
                        } 
0 Answers
Related