411 questions
32 votes
2 answers
12k views
How can I get rid of index dots on TabView with PageTabViewStyle in SwiftUI?
I have the following code but can't seem to remove the dots at the bottom of the TabView. struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @State ...
30 votes
3 answers
3k views
OnAppear calls unexpectedly when Keyboard Appears in SwiftUI
I am experiencing very odd behavior in SwiftUI 2.0 and iOS14. When the keyboard appears on the screen, the OnAppear method of other tab's view called automatically. However, this works fine Xcode 11.7 ...
19 votes
7 answers
19k views
SwiftUI Hide TabView bar inside NavigationLink views
I have a TabView and separate NavigationView stacks for every Tab item. It works well but when I open any NavigationLink the TabView bar is still displayed. I'd like it to disappear whenever I click ...
19 votes
4 answers
15k views
SwiftUI TabView: how to detect click on a tab?
I would like to run a function each time a tab is tapped. On the code below (by using onTapGesture) when I tap on a new tab, myFunction is called, but the tabview is not changed. struct DetailView: ...
19 votes
6 answers
9k views
SwiftUI TabView PageTabViewStyle prevent changing tab?
I have a TabView in SwiftUI in the PageViewTabStyle so i can swipe from page to page. I'd like to have a setting that "locks" the current view in place, so the user cannot swipe. Googling ...
14 votes
3 answers
20k views
How to implement iOS 26 Liquid Glass tab bar with separate floating action button?
Apple's iOS 26 "Liquid Glass" introduces a new UI paradigm of a tab bar with a separate floating action button off to the side. This seems to be a common UI design used in many of Apple's ...
12 votes
2 answers
9k views
SwiftUI how to keep track of page index in PageTabViewStyle?
I'm trying to keep track of what page the user is on in a TabView that is PageTabViewStyle in SwiftUI but I can't figure out the best way to keep track of the page index? Using .onAppear doesn't work ...
12 votes
2 answers
5k views
Add shadow above SwiftUI's TabView
I'm trying to implement TabView in SwiftUI that has the same color as screen background but also has a shadow above it like in this picture: So far I've been able to properly display color, but I don'...
12 votes
2 answers
4k views
SwiftUI TabView Updating Selection Does Not Update Selected Tab
For some reason updating the selection does not update the selected tab in this very simple example. My expectation would be that it would show Tab 1 initially, and when I press the Toggle Tab button,...
12 votes
2 answers
3k views
SwiftUI - detecting Long Press while keeping TabView swipable
I'm trying to detect a Long Press gesture on TabView that's swipable. The issue is that it disables TabView's swipable behavior at the moment. Applying the gesture on individual VStacks didn't work ...
12 votes
1 answer
4k views
iOS14 SwiftUI How to Disable Scroll on TabView [duplicate]
TabView(selection: $vm.selectedTab) { PlanCard_PositiveDay(vm: vm).tag(0) PlanCard_CountdownDay().tag(1) PlanCard_Basalkcal().tag(2) PlanCard_ActivityDiet().tag(3) PlanCard_Schedule()....
12 votes
1 answer
2k views
Why is makeUIView being called multiple times when within TabView?
My app has a TabView (PageTabViewStyle) and within each tab is a UIViewRepresentable. I have simplified the code to produce a minimum reproducible example below. The problem is that makeUIView is ...
11 votes
1 answer
10k views
SwiftUI onChange() event doesn't work on TabView when swiping
I would like to change the value of a text when the active tab of a TabView changes. I tried using onChange(of: activeTab, perform: {}) to change the value of the state variable that stores the text ...
11 votes
2 answers
10k views
SwiftUI navigation titles within TabView
For the reason outlined in the answer outlined in this question SwiftUI TabView brightness views vertical location the menu structure for my app is NavigationView -> TabView -> sub view with ...
11 votes
3 answers
6k views
macOS SwiftUI App TabView with Segmented Control in Toolbar
I am trying to create a macOS app with SwiftUI. I need a TabView or something similar, but when I use TabView the segmented control is not in the macOS Toolbar. Here is an example of what I would like:...