I am using SwiftUI Picker (MenuPickerStyle()). The options in the picker expands perfectly like the images below.
Code :
import SwiftUI
struct TestView: View {
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
@State private var selectedMonth = ""
var body: some View {
Picker(selectedMonth, selection: $selectedMonth) {
ForEach(months, id: \.self) {
Text($0)
}
}
.frame(maxWidth: .infinity, alignment: .top)
.pickerStyle(MenuPickerStyle())
.foregroundColor(Color.black)
.font(.custom("poppins_regular", size: 15))
}
}
struct TestView_Previews: PreviewProvider {
static var previews: some View {
TestView()
}
}
But this only works when I click on the Picker.
Can I just expand it externally? (3rd screenshot)
Example : Can I expand it by a button click?
Button("Click to expand picker options"){
// Can I expand picker option by this Button click?
}
Picker(selectedMonth, selection: $selectedMonth) {
ForEach(months, id: \.self) {
Text($0)
}
}
.frame(maxWidth: .infinity, alignment: .top)
.pickerStyle(MenuPickerStyle())
.foregroundColor(Color.black)
.font(.custom("poppins_regular", size: 15))
}
