Post

Replies

Boosts

Views

Activity

Custom Label doesn't work (MenuPickerStyle)
Why is there no custom label displayed? Thanks for an answer. struct ContentView: View{     @State var selection = 0     let numbers = [1,2,3,4,5]     var body: some View{         Picker(selection: $selection, content: {             ForEach(numbers,id:\.self){i in                 Text("Number \(i)").tag(i)             }         }, label: {             Text("\(selection)")                 .padding()                 .background(Circle().foregroundColor(.red))         })         .pickerStyle(MenuPickerStyle())     } }
1
0
1.3k
Sep ’22
Menu Picker gets pushed up by keyboard safeArea
Although having a .ignoresSafeArea modifier attached, the button for the menu gets pushed up a little bit. I don't know why. When using a regular picker with .pickerStyle(MenuPickerStyle()) I can't get a custom label. Thanks for an answer import SwiftUI struct ContentView: View { @State var text = "" @State var selection = "" let foo = ["a","b","c"] @FocusState var focus var body: some View{ GeometryReader{_ in ZStack{ Color(UIColor.systemGray6) ScrollView{ VStack{ TextField("title", text: $text) .focused($focus) .frame(maxWidth: .infinity, maxHeight: .infinity) .border(.orange) Spacer() } .frame(maxWidth: .infinity, maxHeight: .infinity) } overlayInZStack // <-------- here is the overlay } .frame(maxWidth: .infinity, maxHeight: .infinity) } .ignoresSafeArea(.keyboard, edges: .bottom) // <------ modifier attached } var overlayInZStack: some View { VStack{ Spacer() HStack{ Button("focus"){ focus = true } Menu(content:{ // <----- menu picker in bottom tool row Picker(selection: $selection, label: EmptyView() , content: { ForEach(foo,id:\.self){f in Label(f, systemImage: "house") .tag(f) } }) Picker(selection: $selection, label: EmptyView() , content: { Label("test", systemImage: "plus.circle.fill") .tag("test 1") }) },label:{ Image(systemName: "house") .padding(10) .background(Circle().foregroundColor(.red)) .border(Color.red) }) .border(Color.orange) } .border(Color.green) } .frame(maxWidth: .infinity, maxHeight: .infinity) .border(Color.black) } }
0
0
625
Sep ’22
Custom Label doesn't work (MenuPickerStyle)
Why is there no custom label displayed? Thanks for an answer. struct ContentView: View{     @State var selection = 0     let numbers = [1,2,3,4,5]     var body: some View{         Picker(selection: $selection, content: {             ForEach(numbers,id:\.self){i in                 Text("Number \(i)").tag(i)             }         }, label: {             Text("\(selection)")                 .padding()                 .background(Circle().foregroundColor(.red))         })         .pickerStyle(MenuPickerStyle())     } }
Replies
1
Boosts
0
Views
1.3k
Activity
Sep ’22
Menu Picker gets pushed up by keyboard safeArea
Although having a .ignoresSafeArea modifier attached, the button for the menu gets pushed up a little bit. I don't know why. When using a regular picker with .pickerStyle(MenuPickerStyle()) I can't get a custom label. Thanks for an answer import SwiftUI struct ContentView: View { @State var text = "" @State var selection = "" let foo = ["a","b","c"] @FocusState var focus var body: some View{ GeometryReader{_ in ZStack{ Color(UIColor.systemGray6) ScrollView{ VStack{ TextField("title", text: $text) .focused($focus) .frame(maxWidth: .infinity, maxHeight: .infinity) .border(.orange) Spacer() } .frame(maxWidth: .infinity, maxHeight: .infinity) } overlayInZStack // <-------- here is the overlay } .frame(maxWidth: .infinity, maxHeight: .infinity) } .ignoresSafeArea(.keyboard, edges: .bottom) // <------ modifier attached } var overlayInZStack: some View { VStack{ Spacer() HStack{ Button("focus"){ focus = true } Menu(content:{ // <----- menu picker in bottom tool row Picker(selection: $selection, label: EmptyView() , content: { ForEach(foo,id:\.self){f in Label(f, systemImage: "house") .tag(f) } }) Picker(selection: $selection, label: EmptyView() , content: { Label("test", systemImage: "plus.circle.fill") .tag("test 1") }) },label:{ Image(systemName: "house") .padding(10) .background(Circle().foregroundColor(.red)) .border(Color.red) }) .border(Color.orange) } .border(Color.green) } .frame(maxWidth: .infinity, maxHeight: .infinity) .border(Color.black) } }
Replies
0
Boosts
0
Views
625
Activity
Sep ’22