我在我的 SwiftUI 應用程式中使用選項卡視圖。我想禁用它向左滑動并寫入以移動到其他頁面。我檢查了
有人對此有解決方案嗎?
uj5u.com熱心網友回復:
實際上問題是因為您的視圖是透明的,因此由于命中測驗失敗而忽略了手勢。
.contentShape解決方法是使用修飾符使其明確可命中測驗。
使用 Xcode 13.4 / iOS 15.5 測驗
TabView(selection: $selectedIndex) {
FirstView().tag(0)
.contentShape(Rectangle()).gesture(DragGesture()) // << here !!
SecondView().tag(1)
.contentShape(Rectangle()).gesture(DragGesture())
ThirdView().tag(2)
.contentShape(Rectangle()).gesture(DragGesture())
}.tabViewStyle(.page(indexDisplayMode: .never))
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/495245.html
標籤:迅速 迅捷 选项卡视图 滑动手势 swiftui-tabview
