Swiftui Overlay Blocking List Scroll Events

SwiftUI DragGesture blocking List vertical scroll?

The solution is to give different distance for swipe, like below

struct cl_task: View {
@State private var offset: CGSize = .zero

var body: some View {

// give 25 distance makes vertical scroll enabled !!
let drag = DragGesture(minimumDistance: 25, coordinateSpace: .local)

.onChanged {

Tested with Xcode 12.4 / iOS 14.4

demo

SwiftUI overlay cancels touches

The following code works on Xcode 11.2 / iOS 13.2

struct TestButtonWithOverlay: View {
var body: some View {
Button(action: {
print("Pressed")
}) {
Text("Press me")
.padding()
}

.overlay(
LinearGradient(
gradient: Gradient(colors: [.clear, Color.black.opacity(0.3)]),
startPoint: .top,
endPoint: .bottom
)
.allowsHitTesting(false) // !!! must be exactly here
)
}
}

SwiftUI: Dynamically move navigationBar items on List scroll

i am not sure what you want, but the reason for this behavior is your offset.

Try this:

struct ContentView: View {
var body: some View {
NavigationView {
List {
ForEach(UIFont.familyNames, id: \.self) { name in
Text(name)
}
}.navigationBarTitle("Title")
.navigationBarItems(leading:
HStack {
Button(action: {
// action
}) {
HStack {
Text("Upcoming")
Image(systemName: "chevron.down.circle")
.font(.system(size: 21, weight: .regular))
// .offset(x: 169, y: 47)
.foregroundColor(Color.orange)
}
}

})
}
}
}

Sample Image

Sample Image



Related Topics



Leave a reply



Submit