Provide views, controls, and layout structures for declaring your app's user interface using SwiftUI.

SwiftUI Documentation

Posts under SwiftUI subtopic

Post

Replies

Boosts

Views

Activity

SwiftUI View Not Initialized on Background Relaunch (CoreBluetooth / Cold Start?)
I have a question regarding cold start and pre-warming behavior on iOS. I’m developing a SwiftUI app that continuously receives data from a BLE device in the background. We’ve observed that after the BLE stream stops, the OS often terminates our app. Later, when the sensor comes back into range, iOS appears to relaunch (or reinitialize) the app. In our app, we use a WindowGroup like this: WindowGroup { AppView(store: store) } We’ve placed our BLE reconnection logic inside a .task modifier in AppView. What’s confusing is this: Most of the time, when the app is relaunched, AppView is created and the .task runs as expected. However, in about 1 out of 10 cases, AppView is not created at all, so the .task does not execute. I’m trying to understand: Under what conditions does iOS relaunch an app without fully initializing the SwiftUI view hierarchy? Is this related to pre-warming or background relaunch mechanisms (e.g., CoreBluetooth state restoration)? What determines whether the WindowGroup and root view are actually instantiated? Any insight into the system’s relaunch behavior or lifecycle in this scenario would be greatly appreciated.
1
0
52
12h
View Navigation Title Disappears on watchOS Target When Built With Xcode 26+
I have a SwiftUI view in a watch companion app, and when I build my app with Xcode 26.2 or 26.3, the navigation title on a presented screen disappears after the watch screen goes dark. So, the navigation title is only visible when the screen is first presented and not again after the watch screen goes dark, for example when the user lowers their arm. Please see the screenshots for a better understanding. Notice that the "Bench Press" text is not visible in the third image. Also, I’ve confirmed that this does not happen when the app is built with Xcode 16.4. First Image (initial presentation of the screen): Second Image (watch screen goes dark): Third Image (watch screen goes back on, title missing): Although I've confirmed that this is related to Xcode versioning, and it happens on multiple screens, here is the redacted version of this SwiftUI view that is shown in the screenshots, in case it helps: var body: some View { NavigationStack(path: $viewModel.pushedViews) { TabView(selection: $selectedTab) { ... ZStack { List { ForEach(Array(viewModel.setModels.enumerated()), id: \.element) { index, setModel in VStack(spacing: 8.0) { SetContentView() } } ... } .listStyle(.plain) .buttonStyle(.plain) VStack { WatchRestTimerView(viewModel: viewModel.restTimerViewModel) Spacer() } } .tag(WatchExerciseLoggingTab.logExercise) // HERE IS THE TITLE SET .navigationTitle(viewModel.name) NowPlayingView().tag(WatchExerciseLoggingTab.nowPlaying) } .tabViewStyle(PageTabViewStyle()) .navigationDestination(for: WatchWeightAndSetExerciseSummaryPushedView.self, destination: { _ in RedactedView() }) } } This prevents me from migrating to Xcode 26, I would also appreciate if anyone has a work around until there is a fix for this, I mean I can stop using navigation title and add a Text at the top but it is not quite the same UI experience we get from the navigation title in a watch app.
0
0
16
13h
TabView's Tab Label Image symbolEffect not allowed?
Hi, I'm using a TabView and for a given case I wish to have the icon of the Tab animated by symbolEffect to signify a state. The symbolEffect however doesn't seem to have an effect when used on a tab's label image. Is it really not possible? Tab(value: .hello) { EmptyView() } label: { Image(systemName: "hand.wave.fill") .symbolEffect(.wiggle, options: .repeating) } I still wish to use the TabView because it's amazing.
2
0
50
1d
Keyboard Toolbar Padding iOS26
When I create a SwiftUI toolbar item with placement of .keyboard on iOS 26, the item appears directly on top of and in contact with the keyboard. This does not look good visually nor does it match the behavior seen in Apple's apps, such as Reminders. Adding padding to the contents of the toolbar item only expands the size of the item but does not separate the capsule background of the item from the keyboard. How can I add vertical padding or spacing to separate the toolbar item capsule from the keyboard?
Topic: UI Frameworks SubTopic: SwiftUI
10
8
1.1k
2d
Navigation title scroll issue in iOS 26
Navigation title scroll along with the content in iOS 26. working fine in iOS 18 and below. One of my UI component is outside the scrollview which is causing the issue. var body: some View { VStack { Rectangle() .frame(maxWidth: .infinity) .frame(height: 60) .padding(.horizontal) .padding(.top) ScrollView { ForEach(0...5, id: \.self) { _ in RoundedRectangle(cornerRadius: 10) .fill(.green) .frame(maxWidth: .infinity) .frame(height: 100) .padding(.horizontal) } } } .navigationTitle("Hello World") } }
1
0
194
3d
fullScreenCover & Sheet modifier lifecycles
Hello everyone, I’m running into an issue where a partial sheet repeatedly presents and dismisses in a loop. Setup The main screen is presented using fullScreenCover From that screen, a button triggers a standard partial-height sheet The sheet is presented using .sheet(item:) Expected Behavior Tapping the button should present the sheet once and allow it to be dismissed normally. Actual Behavior After the sheet is triggered, it continuously presents and dismisses. What I’ve Verified The bound item is not being reassigned in either the parent or the presented view There is no .task, .onAppear, or .onChange that sets the item again The loop appears to happen without any explicit state updates Additional Context I encountered a very similar issue when iOS 26.0 was first released At that time, moving the .sheet modifier to a higher parent level resolved the issue The problem has now returned on iOS 26.4 beta I’m currently unable to reproduce this in a minimal sample project, which makes it unclear whether: this is a framework regression, or I’m missing a new presentation requirement Environment iOS: 26.4 beta Xcode: 26.4 beta I’ve attached a screen recording of the behavior. Has anyone else experienced this with a fullScreenCover → sheet flow on iOS 26.4? Any guidance or confirmation would be greatly appreciated. Thank you!
3
0
220
3d
iOS 26: Interactive sheet dismissal causes layout hitch in underlying SwiftUI view
I’ve been investigating a noticeable animation hitch when interactively dismissing a sheet over a SwiftUI screen with moderate complexity. This was not the case on iOS 18, so I’m curious if others are seeing the same on iOS 26 or have found any mitigations. When dismissing a sheet via the swipe gesture, there’s a visible hitch right after lift-off. The hitch comes from layout work in the underlying view (behind the sheet) The duration scales with the complexity of that view (e.g. number of TextFields/layout nodes) The animation for programmatic dismiss (e.g. tapping a “Done” button) is smooth, although it hangs for a similar amount of time before dismissing, so it appears that the underlying work still happens. SwiftUI is not reevaluating the body during this (validated with Self._printChanges()), so that is not the cause. Using Instruments, the hitch shows up as a layout spike on the main thread: 54ms UIView layoutSublayersOfLayer 54ms └─ _UIHostingView.layoutSubviews 38ms └─ SwiftUI.ViewGraph.updateOutputs 11ms ├─ partial apply for implicit closure #1 in closure #1 │ in closure #1 in Attribute.init<A>(_:) 4ms └─ -[UIView For the same hierarchy with varying complexity: ~3 TextFields in a List: ~25ms (not noticeable) ~20+ TextFields: ~60ms (clearly visible hitch) The same view hierarchy on iOS 18 did not exhibit a visible hitch. I’ve tested this on an iOS 26.4 device and simulator. I’ve also included a minimum reproducible example that illustrates this: struct ContentView: View { @State var showSheet = false var body: some View { NavigationStack { ScrollView { ForEach(0..<120) { _ in RowView() } } .navigationTitle("Repro") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Present") { showSheet = true } } } .sheet(isPresented: $showSheet) { PresentedSheet() } } } } struct RowView: View { @State var first = "" @State var second = "" var body: some View { VStack(alignment: .leading, spacing: 12) { Text("Row") .font(.headline) HStack(spacing: 12) { TextField("First", text: $first) .textFieldStyle(.roundedBorder) TextField("Second", text: $second) .textFieldStyle(.roundedBorder) } HStack(spacing: 12) { Text("Third") Text("Fourth") Image(systemName: "chevron.right") } } } } struct PresentedSheet: View { @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { List {} .navigationTitle("Swipe To Dismiss Me") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Done") { dismiss() } } } } } } Is anyone else experiencing this and have any mitigations been found beyond reducing view complexity? I’ve filed a feedback report under FB22501630.
1
0
111
3d
How to achieve liquid glass button morph transition
Hi guys, I’m new on SwiftUI world. I wanted to ask how to achieve this kind of morph transition with ToolbarItem button just like the picture attached below. I have tried using Menu & confirmationDialog API but i didn’t achieve the same kind of looks here. Is there some kind of native API for this kind of transition? Thanks in advance guys 😁👍
Topic: UI Frameworks SubTopic: SwiftUI
1
0
54
4d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp
1
0
79
4d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp NavigationStack { ScrollView { HeroView() } .ignoresSafeArea(edges: .top) .navigationTitle("Cinema") .toolbarTitleDisplayMode(.inlineLarge) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) .navigationDestination(for: Route.self) { route in DetailView(movie: route.movie) } } var body: some View { ScrollView { HeaderPosterView() } .ignoresSafeArea(edges: .top) .navigationBarTitleDisplayMode(.inline) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) } }
0
0
100
6d
Disabling card zoom effect on certain transitions
I have attached a screenshot showing the type of behavior in Apple's own Weather app that I am looking to disable in my own app. There is a zoom / card effect where the presenting view shrinks / zooms in the background, exposing a different background color that can look out of place. Notice that when dragging the map view to dismiss it, the views behind it are zoomed in exposing a different background. The presenting view that has this "card" effect has hard edges that do not match the screens corner radius as well, so it just looks out of place. Using this as an example, what would be the way to keep this matched zoom transition but keeping the Weather's background still going edge to edge? In my app I am trying to keep my mesh gradient edge to edge and not zoomed in with black or white borders in a similar situation to what we are seeing in the Weather app on 26.4 Let me know if I need to explain it more. Thank you!
Topic: UI Frameworks SubTopic: SwiftUI
0
0
52
6d
top keyboard pill with up/down and close
I just finished writing a tonn of codes to get a pill on top of my keyboards that gives you the option to go up/down and close the keyboard. Very similar to what I see on safari keyboard. It should be included in the next SwiftUI as a modifier.... it would be so helpful
Topic: UI Frameworks SubTopic: SwiftUI
0
0
124
6d
Understanding SwiftUI toolbars
I have two apps written in SwiftUI. Both use a NavigationSplitView as their primary content with a list-based sidebar. Both apps have a few toolbar items offering functionality relevant to the application purpose. Both sidebars have toolbar items, declared using the .toolbar view modifier, that add ToolbarItems to their view (a "filter" menu). Both the apps' main content view use .toolbar to add some ToolbarItems to the main content toolbar as well. Both also include the SidebarCommands() command group. My question is this: in one app, when I click the Hide Sidebar button, the toolbar items that were attached to the sidebar move to the main toolbar. In my second app, the toolbar items move to the "More" disclosure menu at the end of the toolbar. Video showing sidebar leading Video showing sidebar trailing I want behavior like the first app (where the toolbar items end up in the leading edge of the main toolbar) in the second app, but I've scrubbed through both applications' toolbar code, I've had coding assistants compare the two, I've tried stripping down the toolbar items to remove all but the Hide Sidebar. Nothing I can discover shows me why one app moves the toolbar items to the main toolbar up front, while the other moves them to the back. Am I missing something about how to declare toolbar items? Is there some visibility priority thing I’m missing?
Topic: UI Frameworks SubTopic: SwiftUI
4
0
103
6d
Layout Bug: Button icon lags after keyboard dismissal in SwiftUI
Hello everyone, I am experiencing a layout issue in a SwiftUI project where an icon inside a button becomes laggy after the keyboard is dismissed. I have a custom input bar designed with an HStack containing a TextField and a Button with a microphone.fill icon. The entire HStack is styled using a .clipShape(.capsule) and a background color and I am using @FocusState to manage the keyboard focus. When the user taps the TextField, the keyboard appears, and the entire view moves up correctly to make room. But when the keyboard is dismissed by the button action isPromptFieldFocused = false, the capsule-shaped background and the text field return to their original position, but the icon on the button (and just the icon) doesn't. The microphone icon inside the button does not follow the movement. It remains stuck at the "keyboard-up" height for a moment until the view is refreshed, breaking the UI. And by the way, the icon correctly returns to its original position with the other UI elements if the user presses the return key on their keyboard. import SwiftUI struct ContentView: View { @State var userText: String = "" @FocusState var isTextFieldFocused: Bool var body: some View { HStack { TextField("Type here...", text: $userText) .focused($isTextFieldFocused) .textInputAutocapitalization(.sentences) .textFieldStyle(PlainTextFieldStyle()) .padding(.leading, 12) .padding(.trailing, 4) Button(action: { print("Microphone pressed") isPromptFieldFocused = false }) { Image(systemName: "microphone.fill") .font(.system(size: 22, weight: .semibold)) .foregroundStyle(.white) .padding(14) } .background(Color.black) .clipShape(Circle()) .padding(.trailing, 14) .padding(.vertical, 14) } .background(Color.lightGray) .clipShape(Capsule()) .padding() } } I've already tried using different animation types (e.g., .default, .spring) and explicitly setting the frame of the button. Has anyone encountered this specific behavior where an Image(systemName:) ignores the parent container's transition during keyboard dismissal? I would appreciate any insights on how to ensure the entire HStack and its children animate back down in sync.
0
0
103
1w
Initial presentation of popover hangs when shown from a button in the toolbar
I have a simple reproducer here: struct ContentView: View { @State private var isOn = false @State private var isPresented = false var body: some View { NavigationStack { Color.blue .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Press here") { isPresented = true } .popover(isPresented: $isPresented) { Color.green .frame(idealWidth: 400, idealHeight: 500) .presentationCompactAdaptation(.popover) } } } } } } When I tap on the button in the toolbar you can see there is a hang then the popover shows. Then every time after there is no longer a hang so this seems like a bug. Any ideas? I'm using Xcode 26.3 and a iPad Pro 13-inch (M5) (26.4) simulator.
3
3
177
1w
navigationTransition Rendering Glitch for Stroke Borders
If you use .navigationTransition(.zoom(sourceID: zoomID, in: namespace)) with a carousel or a card view, which uses : .stroke(Color.secondary.opacity(0.5), lineWidth: 5) It causes the border stroke to render incorrectly, and even in some cases, the card glitches out and disappears from the screen. The card is clickable but there is no entity in the placeholder of that place.
0
0
29
1w
Double appearance of a button in .bottomBar ToolbarItem
I'm trying to understand why would a single button appear twice in the toolbar, like so: Do you see the eclipsed button peeking from underneath the top button? It's the same button, somehow doubled or cloned, or replicated. To reproduce it, I only needed to create a fresh iOS project in Xcode and apply this code change: diff --git a/BugRepro20260409/ContentView.swift b/BugRepro20260409/ContentView.swift index 426b298..d22433f 100644 --- a/BugRepro20260409/ContentView.swift +++ b/BugRepro20260409/ContentView.swift @@ -28,7 +28,7 @@ struct ContentView: View { ToolbarItem(placement: .navigationBarTrailing) { EditButton() } - ToolbarItem { + ToolbarItem(placement: .bottomBar) { Button(action: addItem) { Label("Add Item", systemImage: "plus") } This is all I needed to do for the double-vision button. Why would this button appear twice when moved to .bottomBar? By the way, when moved to the side and displayed on a smaller device like iPhone SE, the duplication is quite jarring: Interestingly, both buttons are active, and both trigger the same code path. Any ideas what's going on? ContentView.swift
0
0
40
1w
Navigation title issue in iOS 26
Navigation title also scroll below the content when using scrollview. working fine in iOS 18 and below. one of the UI component is outside the scrollview which is causing the issue. struct ContentView: View { var body: some View { VStack { Rectangle() .frame(maxWidth: .infinity) .frame(height: 60) .padding(.horizontal) .padding(.top) ScrollView { ForEach(0...5, id: \.self) { _ in RoundedRectangle(cornerRadius: 10) .fill(.green) .frame(maxWidth: .infinity) .frame(height: 100) .padding(.horizontal) } } } .navigationTitle("Hello World") } }
0
0
120
1w
Why is the .opacity AnyTransition is marked as nonisolated(unsafe)
Because of this, in Swift 6 mode, Xcode complains about the access, and ask me to use unsafe keyword. To fix it, I need to do this: Anyone can explain this abrupt nonisolated(unsafe) change?
Replies
0
Boosts
0
Views
31
Activity
11h
SwiftUI View Not Initialized on Background Relaunch (CoreBluetooth / Cold Start?)
I have a question regarding cold start and pre-warming behavior on iOS. I’m developing a SwiftUI app that continuously receives data from a BLE device in the background. We’ve observed that after the BLE stream stops, the OS often terminates our app. Later, when the sensor comes back into range, iOS appears to relaunch (or reinitialize) the app. In our app, we use a WindowGroup like this: WindowGroup { AppView(store: store) } We’ve placed our BLE reconnection logic inside a .task modifier in AppView. What’s confusing is this: Most of the time, when the app is relaunched, AppView is created and the .task runs as expected. However, in about 1 out of 10 cases, AppView is not created at all, so the .task does not execute. I’m trying to understand: Under what conditions does iOS relaunch an app without fully initializing the SwiftUI view hierarchy? Is this related to pre-warming or background relaunch mechanisms (e.g., CoreBluetooth state restoration)? What determines whether the WindowGroup and root view are actually instantiated? Any insight into the system’s relaunch behavior or lifecycle in this scenario would be greatly appreciated.
Replies
1
Boosts
0
Views
52
Activity
12h
View Navigation Title Disappears on watchOS Target When Built With Xcode 26+
I have a SwiftUI view in a watch companion app, and when I build my app with Xcode 26.2 or 26.3, the navigation title on a presented screen disappears after the watch screen goes dark. So, the navigation title is only visible when the screen is first presented and not again after the watch screen goes dark, for example when the user lowers their arm. Please see the screenshots for a better understanding. Notice that the "Bench Press" text is not visible in the third image. Also, I’ve confirmed that this does not happen when the app is built with Xcode 16.4. First Image (initial presentation of the screen): Second Image (watch screen goes dark): Third Image (watch screen goes back on, title missing): Although I've confirmed that this is related to Xcode versioning, and it happens on multiple screens, here is the redacted version of this SwiftUI view that is shown in the screenshots, in case it helps: var body: some View { NavigationStack(path: $viewModel.pushedViews) { TabView(selection: $selectedTab) { ... ZStack { List { ForEach(Array(viewModel.setModels.enumerated()), id: \.element) { index, setModel in VStack(spacing: 8.0) { SetContentView() } } ... } .listStyle(.plain) .buttonStyle(.plain) VStack { WatchRestTimerView(viewModel: viewModel.restTimerViewModel) Spacer() } } .tag(WatchExerciseLoggingTab.logExercise) // HERE IS THE TITLE SET .navigationTitle(viewModel.name) NowPlayingView().tag(WatchExerciseLoggingTab.nowPlaying) } .tabViewStyle(PageTabViewStyle()) .navigationDestination(for: WatchWeightAndSetExerciseSummaryPushedView.self, destination: { _ in RedactedView() }) } } This prevents me from migrating to Xcode 26, I would also appreciate if anyone has a work around until there is a fix for this, I mean I can stop using navigation title and add a Text at the top but it is not quite the same UI experience we get from the navigation title in a watch app.
Replies
0
Boosts
0
Views
16
Activity
13h
TabView's Tab Label Image symbolEffect not allowed?
Hi, I'm using a TabView and for a given case I wish to have the icon of the Tab animated by symbolEffect to signify a state. The symbolEffect however doesn't seem to have an effect when used on a tab's label image. Is it really not possible? Tab(value: .hello) { EmptyView() } label: { Image(systemName: "hand.wave.fill") .symbolEffect(.wiggle, options: .repeating) } I still wish to use the TabView because it's amazing.
Replies
2
Boosts
0
Views
50
Activity
1d
Keyboard Toolbar Padding iOS26
When I create a SwiftUI toolbar item with placement of .keyboard on iOS 26, the item appears directly on top of and in contact with the keyboard. This does not look good visually nor does it match the behavior seen in Apple's apps, such as Reminders. Adding padding to the contents of the toolbar item only expands the size of the item but does not separate the capsule background of the item from the keyboard. How can I add vertical padding or spacing to separate the toolbar item capsule from the keyboard?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
10
Boosts
8
Views
1.1k
Activity
2d
Navigation title scroll issue in iOS 26
Navigation title scroll along with the content in iOS 26. working fine in iOS 18 and below. One of my UI component is outside the scrollview which is causing the issue. var body: some View { VStack { Rectangle() .frame(maxWidth: .infinity) .frame(height: 60) .padding(.horizontal) .padding(.top) ScrollView { ForEach(0...5, id: \.self) { _ in RoundedRectangle(cornerRadius: 10) .fill(.green) .frame(maxWidth: .infinity) .frame(height: 100) .padding(.horizontal) } } } .navigationTitle("Hello World") } }
Replies
1
Boosts
0
Views
194
Activity
3d
fullScreenCover & Sheet modifier lifecycles
Hello everyone, I’m running into an issue where a partial sheet repeatedly presents and dismisses in a loop. Setup The main screen is presented using fullScreenCover From that screen, a button triggers a standard partial-height sheet The sheet is presented using .sheet(item:) Expected Behavior Tapping the button should present the sheet once and allow it to be dismissed normally. Actual Behavior After the sheet is triggered, it continuously presents and dismisses. What I’ve Verified The bound item is not being reassigned in either the parent or the presented view There is no .task, .onAppear, or .onChange that sets the item again The loop appears to happen without any explicit state updates Additional Context I encountered a very similar issue when iOS 26.0 was first released At that time, moving the .sheet modifier to a higher parent level resolved the issue The problem has now returned on iOS 26.4 beta I’m currently unable to reproduce this in a minimal sample project, which makes it unclear whether: this is a framework regression, or I’m missing a new presentation requirement Environment iOS: 26.4 beta Xcode: 26.4 beta I’ve attached a screen recording of the behavior. Has anyone else experienced this with a fullScreenCover → sheet flow on iOS 26.4? Any guidance or confirmation would be greatly appreciated. Thank you!
Replies
3
Boosts
0
Views
220
Activity
3d
iOS 26: Interactive sheet dismissal causes layout hitch in underlying SwiftUI view
I’ve been investigating a noticeable animation hitch when interactively dismissing a sheet over a SwiftUI screen with moderate complexity. This was not the case on iOS 18, so I’m curious if others are seeing the same on iOS 26 or have found any mitigations. When dismissing a sheet via the swipe gesture, there’s a visible hitch right after lift-off. The hitch comes from layout work in the underlying view (behind the sheet) The duration scales with the complexity of that view (e.g. number of TextFields/layout nodes) The animation for programmatic dismiss (e.g. tapping a “Done” button) is smooth, although it hangs for a similar amount of time before dismissing, so it appears that the underlying work still happens. SwiftUI is not reevaluating the body during this (validated with Self._printChanges()), so that is not the cause. Using Instruments, the hitch shows up as a layout spike on the main thread: 54ms UIView layoutSublayersOfLayer 54ms └─ _UIHostingView.layoutSubviews 38ms └─ SwiftUI.ViewGraph.updateOutputs 11ms ├─ partial apply for implicit closure #1 in closure #1 │ in closure #1 in Attribute.init<A>(_:) 4ms └─ -[UIView For the same hierarchy with varying complexity: ~3 TextFields in a List: ~25ms (not noticeable) ~20+ TextFields: ~60ms (clearly visible hitch) The same view hierarchy on iOS 18 did not exhibit a visible hitch. I’ve tested this on an iOS 26.4 device and simulator. I’ve also included a minimum reproducible example that illustrates this: struct ContentView: View { @State var showSheet = false var body: some View { NavigationStack { ScrollView { ForEach(0..<120) { _ in RowView() } } .navigationTitle("Repro") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Present") { showSheet = true } } } .sheet(isPresented: $showSheet) { PresentedSheet() } } } } struct RowView: View { @State var first = "" @State var second = "" var body: some View { VStack(alignment: .leading, spacing: 12) { Text("Row") .font(.headline) HStack(spacing: 12) { TextField("First", text: $first) .textFieldStyle(.roundedBorder) TextField("Second", text: $second) .textFieldStyle(.roundedBorder) } HStack(spacing: 12) { Text("Third") Text("Fourth") Image(systemName: "chevron.right") } } } } struct PresentedSheet: View { @Environment(\.dismiss) private var dismiss var body: some View { NavigationStack { List {} .navigationTitle("Swipe To Dismiss Me") .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Done") { dismiss() } } } } } } Is anyone else experiencing this and have any mitigations been found beyond reducing view complexity? I’ve filed a feedback report under FB22501630.
Replies
1
Boosts
0
Views
111
Activity
3d
How to achieve liquid glass button morph transition
Hi guys, I’m new on SwiftUI world. I wanted to ask how to achieve this kind of morph transition with ToolbarItem button just like the picture attached below. I have tried using Menu & confirmationDialog API but i didn’t achieve the same kind of looks here. Is there some kind of native API for this kind of transition? Thanks in advance guys 😁👍
Topic: UI Frameworks SubTopic: SwiftUI
Replies
1
Boosts
0
Views
54
Activity
4d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp
Replies
1
Boosts
0
Views
79
Activity
4d
Interactive Sheet dismiss laggy on iOS26
On iOS 26 I’m seeing a small stutter when dismissing a SwiftUI .sheet with the swipe-down gesture. The same code was smooth on iOS 18. Has anyone else experienced this issue?
Replies
2
Boosts
0
Views
168
Activity
5d
Navigation bar flickers when pushing to a different screen
Hi everyone, I’m building a SwiftUI app using NavigationStack and running into a weird nav bar issue. For the setup I have a 'home' screen with a vertical ScrollView and a large edge-to-edge header that extends under the top safe area (using .ignoresSafeArea(edges: .top)). I also have a 'detail' screen with a similar immersive layout, where the header/poster image sits at the top and the ScrollView also extends under the top area. I’m using the native navigation bar on both screens and default back button, not a custom nav bar, and I’m not manually configuring UINavigationBarAppearance, I'm just relying on SwiftUI’s default/automatic toolbar behavior. The problem I’m facing is when I push from home to the detail screen, the top nav area briefly flickers and shows the system navigation bar/material background (white in light mode, black in dark mode). It’s clearly the system material, not the poster/image underneath. The screen initially renders with that nav bar state (white/dark), and only after I start scrolling does it correct itself and visually align with the header/background behind it. What I'm thinking is that maybe the detail screen initially renders with systemBackground, so the nav bar uses its default (standard) appearance on the first frame, and only after layout/interaction, once the image-derived background settles, does it switch to the correct scroll-edge/transparent style. One important thing, if I hide the nav bar on the detail screen using .toolbar(.hidden, for: .navigationBar), the issue disappears completely. So this seems specifically tied to the native nav bar’s initial render/appearance timing during the push, rather than just the layout or image loading. I’d prefer to keep the native nav bar and back button rather than implement a custom approach. Has anyone faced this issue before, or is there a correct way to structure edge-to-edge content under the nav bar so it renders properly on first push? Video of the issue: https://imgur.com/a/OYHtYbp NavigationStack { ScrollView { HeroView() } .ignoresSafeArea(edges: .top) .navigationTitle("Cinema") .toolbarTitleDisplayMode(.inlineLarge) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) .navigationDestination(for: Route.self) { route in DetailView(movie: route.movie) } } var body: some View { ScrollView { HeaderPosterView() } .ignoresSafeArea(edges: .top) .navigationBarTitleDisplayMode(.inline) .toolbarBackgroundVisibility(.automatic, for: .navigationBar) } }
Replies
0
Boosts
0
Views
100
Activity
6d
Disabling card zoom effect on certain transitions
I have attached a screenshot showing the type of behavior in Apple's own Weather app that I am looking to disable in my own app. There is a zoom / card effect where the presenting view shrinks / zooms in the background, exposing a different background color that can look out of place. Notice that when dragging the map view to dismiss it, the views behind it are zoomed in exposing a different background. The presenting view that has this "card" effect has hard edges that do not match the screens corner radius as well, so it just looks out of place. Using this as an example, what would be the way to keep this matched zoom transition but keeping the Weather's background still going edge to edge? In my app I am trying to keep my mesh gradient edge to edge and not zoomed in with black or white borders in a similar situation to what we are seeing in the Weather app on 26.4 Let me know if I need to explain it more. Thank you!
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
52
Activity
6d
top keyboard pill with up/down and close
I just finished writing a tonn of codes to get a pill on top of my keyboards that gives you the option to go up/down and close the keyboard. Very similar to what I see on safari keyboard. It should be included in the next SwiftUI as a modifier.... it would be so helpful
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
124
Activity
6d
Understanding SwiftUI toolbars
I have two apps written in SwiftUI. Both use a NavigationSplitView as their primary content with a list-based sidebar. Both apps have a few toolbar items offering functionality relevant to the application purpose. Both sidebars have toolbar items, declared using the .toolbar view modifier, that add ToolbarItems to their view (a "filter" menu). Both the apps' main content view use .toolbar to add some ToolbarItems to the main content toolbar as well. Both also include the SidebarCommands() command group. My question is this: in one app, when I click the Hide Sidebar button, the toolbar items that were attached to the sidebar move to the main toolbar. In my second app, the toolbar items move to the "More" disclosure menu at the end of the toolbar. Video showing sidebar leading Video showing sidebar trailing I want behavior like the first app (where the toolbar items end up in the leading edge of the main toolbar) in the second app, but I've scrubbed through both applications' toolbar code, I've had coding assistants compare the two, I've tried stripping down the toolbar items to remove all but the Hide Sidebar. Nothing I can discover shows me why one app moves the toolbar items to the main toolbar up front, while the other moves them to the back. Am I missing something about how to declare toolbar items? Is there some visibility priority thing I’m missing?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
4
Boosts
0
Views
103
Activity
6d
Layout Bug: Button icon lags after keyboard dismissal in SwiftUI
Hello everyone, I am experiencing a layout issue in a SwiftUI project where an icon inside a button becomes laggy after the keyboard is dismissed. I have a custom input bar designed with an HStack containing a TextField and a Button with a microphone.fill icon. The entire HStack is styled using a .clipShape(.capsule) and a background color and I am using @FocusState to manage the keyboard focus. When the user taps the TextField, the keyboard appears, and the entire view moves up correctly to make room. But when the keyboard is dismissed by the button action isPromptFieldFocused = false, the capsule-shaped background and the text field return to their original position, but the icon on the button (and just the icon) doesn't. The microphone icon inside the button does not follow the movement. It remains stuck at the "keyboard-up" height for a moment until the view is refreshed, breaking the UI. And by the way, the icon correctly returns to its original position with the other UI elements if the user presses the return key on their keyboard. import SwiftUI struct ContentView: View { @State var userText: String = "" @FocusState var isTextFieldFocused: Bool var body: some View { HStack { TextField("Type here...", text: $userText) .focused($isTextFieldFocused) .textInputAutocapitalization(.sentences) .textFieldStyle(PlainTextFieldStyle()) .padding(.leading, 12) .padding(.trailing, 4) Button(action: { print("Microphone pressed") isPromptFieldFocused = false }) { Image(systemName: "microphone.fill") .font(.system(size: 22, weight: .semibold)) .foregroundStyle(.white) .padding(14) } .background(Color.black) .clipShape(Circle()) .padding(.trailing, 14) .padding(.vertical, 14) } .background(Color.lightGray) .clipShape(Capsule()) .padding() } } I've already tried using different animation types (e.g., .default, .spring) and explicitly setting the frame of the button. Has anyone encountered this specific behavior where an Image(systemName:) ignores the parent container's transition during keyboard dismissal? I would appreciate any insights on how to ensure the entire HStack and its children animate back down in sync.
Replies
0
Boosts
0
Views
103
Activity
1w
Initial presentation of popover hangs when shown from a button in the toolbar
I have a simple reproducer here: struct ContentView: View { @State private var isOn = false @State private var isPresented = false var body: some View { NavigationStack { Color.blue .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Press here") { isPresented = true } .popover(isPresented: $isPresented) { Color.green .frame(idealWidth: 400, idealHeight: 500) .presentationCompactAdaptation(.popover) } } } } } } When I tap on the button in the toolbar you can see there is a hang then the popover shows. Then every time after there is no longer a hang so this seems like a bug. Any ideas? I'm using Xcode 26.3 and a iPad Pro 13-inch (M5) (26.4) simulator.
Replies
3
Boosts
3
Views
177
Activity
1w
navigationTransition Rendering Glitch for Stroke Borders
If you use .navigationTransition(.zoom(sourceID: zoomID, in: namespace)) with a carousel or a card view, which uses : .stroke(Color.secondary.opacity(0.5), lineWidth: 5) It causes the border stroke to render incorrectly, and even in some cases, the card glitches out and disappears from the screen. The card is clickable but there is no entity in the placeholder of that place.
Replies
0
Boosts
0
Views
29
Activity
1w
Double appearance of a button in .bottomBar ToolbarItem
I'm trying to understand why would a single button appear twice in the toolbar, like so: Do you see the eclipsed button peeking from underneath the top button? It's the same button, somehow doubled or cloned, or replicated. To reproduce it, I only needed to create a fresh iOS project in Xcode and apply this code change: diff --git a/BugRepro20260409/ContentView.swift b/BugRepro20260409/ContentView.swift index 426b298..d22433f 100644 --- a/BugRepro20260409/ContentView.swift +++ b/BugRepro20260409/ContentView.swift @@ -28,7 +28,7 @@ struct ContentView: View { ToolbarItem(placement: .navigationBarTrailing) { EditButton() } - ToolbarItem { + ToolbarItem(placement: .bottomBar) { Button(action: addItem) { Label("Add Item", systemImage: "plus") } This is all I needed to do for the double-vision button. Why would this button appear twice when moved to .bottomBar? By the way, when moved to the side and displayed on a smaller device like iPhone SE, the duplication is quite jarring: Interestingly, both buttons are active, and both trigger the same code path. Any ideas what's going on? ContentView.swift
Replies
0
Boosts
0
Views
40
Activity
1w
Navigation title issue in iOS 26
Navigation title also scroll below the content when using scrollview. working fine in iOS 18 and below. one of the UI component is outside the scrollview which is causing the issue. struct ContentView: View { var body: some View { VStack { Rectangle() .frame(maxWidth: .infinity) .frame(height: 60) .padding(.horizontal) .padding(.top) ScrollView { ForEach(0...5, id: \.self) { _ in RoundedRectangle(cornerRadius: 10) .fill(.green) .frame(maxWidth: .infinity) .frame(height: 100) .padding(.horizontal) } } } .navigationTitle("Hello World") } }
Replies
0
Boosts
0
Views
120
Activity
1w