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)
}
}