[ad_1]
I am fighting a view the place I wish to have a number of pickers embedded in
different views. Once I wrap the pickers in a Type, I get the specified conduct for the
picker however there’s a whole lot of additional house across the pickers that I can not seem to
mechanically regulate.
That is an instance – the house within the pink define appears to be decided by the opposite
view parts not the dimensions of the picker.
I can, in fact, hard-code a body top for the Type however that’s trial and error
and would solely be particular to the system and orientation. I’ve tried a number of
variations of Stacks inside Stacks with padding, GeometryReader and so forth, however I’ve not provide you with any
answer. As an apart, I DO need the picker labels, in any other case I may simply take away
the Type.
I additionally tried setting UITableView.look().tableFooterView in an init() however that didn’t work both.
Here’s a simplified model:
struct ContentView4: View {
@State var selectedNumber1: Int = 1
@State var selectedNumber2: Int = 2
@State var selectedNumber3: Int = 3
var physique: some View {
NavigationView {
VStack(alignment: .main) {
HStack {
Spacer()
Textual content("Examine as much as 3")
.font(.caption)
Spacer()
}//h
Type {//for pickers
Picker(choice: $selectedNumber1, label: Textual content("A")) {
ForEach(0..<10) {
Textual content("($0)")
}
}//picker
Picker(choice: $selectedNumber2, label: Textual content("B")) {
ForEach(0..<10) {
Textual content("($0)")
}
}//picker
Picker(choice: $selectedNumber3, label: Textual content("C")) {
ForEach(0..<10) {
Textual content("($0)")
}
}//picker
}//kind for pickers
.padding(.horizontal, 10)
//.body(top: 200) //do not wish to exhausting code this
VStack(alignment: .main) {
HStack {
Textual content("A")
.body(width: 100)
Textual content("B")
.body(width: 100)
Textual content("C")
.body(width: 100)
}
.padding(.horizontal, 10)
ScrollView(.vertical, showsIndicators: false) {
VStack(alignment: .main){
Textual content("A title line")
.font(.headline)
.padding(.vertical, 5)
HStack {
Textual content("Quantity")
.body(width: 100)
Textual content("Quantity")
.body(width: 100)
Textual content("Quantity")
.body(width: 100)
}
Textual content("One other title line")
.font(.headline)
.padding(.vertical, 5)
HStack {
Textual content("One thing")
.body(width: 100)
Textual content("One thing")
.body(width: 100)
Textual content("One thing")
.body(width: 100)
}
Textual content("A Third title line")
.font(.headline)
.padding(.vertical, 5)
HStack {
Textual content("Extra")
.body(width: 100)
Textual content("Extra")
.body(width: 100)
Textual content("Extra")
.body(width: 100)
}
}
}//scroll
.padding(.horizontal, 10)
}
.navigationBarTitle("Examine Three", displayMode: .inline)
}
}//nav
}//physique
}//struct
Curiously, I’m able to get an answer by eradicating the shape and wrapping every
picker in a menu, like this:
Menu {
Picker(choice: $selectedNumber2, label: EmptyView()) {
ForEach(0..<10) {
Textual content("($0)")
}
}//picker
} label: {
HStack {
Textual content("B")
Spacer()
Picture(systemName: "chevron.proper")
.resizable()
.body(width: 14, top: 14)
}//h
}//menu label
Nonetheless, I nonetheless just like the look of the Type higher if I may mechanically configure
the house across the Type objects.
Any steering can be appreciated. Xcode 13.4, iOS 15.5
[ad_2]

