[ad_1]
I need to implement Horizontal Picker in SwiftUI with native UI and UX.
Right here is my code, how I have been attempting to do it:
import SwiftUI
import Introspect
extension View {
public func introspectUIPickerView(customise: @escaping (UIPickerView) -> ()) -> some View {
inject(UIKitIntrospectionView(
selector: { introspectionView in
guard let viewHost = Introspect.findViewHost(from: introspectionView) else {
return nil
}
return Introspect.previousSibling(containing: UIPickerView.self, from: viewHost)
},
customise: customise
))
}
}
struct S: View {
@State personal var knowledge = 0
personal let objects = ["a", "b", "c", "d", "e", "f", "g"]
var physique: some View {
Picker(choice: $knowledge, label: Textual content("Information")) {
ForEach(objects, id: .self) { textual content in
Textual content(textual content)
.foregroundColor(.crimson)
.scaledToFit()
.rotationEffect(Angle(levels: 90))
}
}
.introspectUIPickerView { view in
view.subviews[1].backgroundColor = UIColor.clear
}
.labelsHidden()
.body(peak: 30)
.rotationEffect(Angle(levels: -90))
.pickerStyle(.wheel)
.clipped()
}
}
struct ContentView: View {
var physique: some View {
VStack {
S()
S()
S()
S()
S()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
The issue on this code is: When I attempt to scroll any picker it scrolls the final picker in VStack. It is because the contact space of the picker is simply too massive. So it overlaps all the opposite pickers. Is it attainable to switch the contact areas of the pickers?
[ad_2]
