Pickers Are Overlapping in iOS 15 Preventing Some of Them to Be Scrolled

Pickers are overlapping in ios 15 preventing some of them to be scrolled

try adding

.compositingGroup()
.clipped()

to your Pickers.

iOS15 - SwiftUI WheelPicker scrollable outside frame and clipped area destructing other interfaces

In NumberPicker try adding compositingGroup just before clipped(...) as:

.compositingGroup()
.clipped(antialiased: true)

Clickable area of SwiftUI Picker overlapping

adding this extension is working for me in 15.4

extension UIPickerView {   
open override var intrinsicContentSize: CGSize {
return CGSize(width: UIView.noIntrinsicMetric, height: super.intrinsicContentSize.height)}
}

found at https://developer.apple.com/forums/thread/687986?answerId=706782022#706782022

SwiftUI - Placing two pickers side-by-side in HStack does not resize pickers

The overlapping in the middle you can fix by adding a clipped() modifier. As for the width, I see them both exactly the same:

Sample Image

struct ContentView: View {
@State var selection1: Int = 0
@State var selection2: Int = 0

@State var integers: [Int] = [0, 1, 2, 3, 4, 5]

var body: some View {
GeometryReader { geometry in
HStack(spacing: 0) {
Picker(selection: self.$selection1, label: Text("Numbers")) {
ForEach(self.integers) { integer in
Text("\(integer)")
}
}
.frame(maxWidth: geometry.size.width / 2)
.clipped()
.border(Color.red)

Picker(selection: self.$selection2, label: Text("Numbers")) {
ForEach(self.integers) { integer in
Text("\(integer)")
}
}
.frame(maxWidth: geometry.size.width / 2)
.clipped()
.border(Color.blue)
}
}
}
}


Related Topics



Leave a reply



Submit