I have set up a (paging) TabView
with .tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
.
I would like the IndexView to be merely visual, i.e. no to respond to any touch.
To achieve this I have set UIPageControl.appearance().isUserInteractionEnabled = false
, which in fact disables paging by touch.
However touches on the UIPageControl
(highlighted in blue by setting its backgroundColor
) are not passed to the List
below: tapping on the blue area will not select the row in the List
underneath.
Is there a way to achieve this?
Here is my sample code (running on iOS 14.0 beta 4):
struct ContentView: View {
init() {
UIPageControl.appearance().backgroundColor = UIColor(red: 0, green: 0, blue: 0.5, alpha: 0.5)
UIPageControl.appearance().isUserInteractionEnabled = false
}
var body: some View {
NavigationView {
TabView {
ForEach (0..<3, id: \.self) { page in
List {
ForEach (0..<30, id: \.self) { row in
NavigationLink(
destination: Text("Page \(page) Row \(row)"),
label: {
Text("Page \(page) Row \(row)")
})
}
}
.tag(page)
}
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .always))
.indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always))
.navigationBarTitle("Title", displayMode: .inline)
.edgesIgnoringSafeArea(.bottom)
}
}
}