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

A Summary of the WWDC25 Group Lab - SwiftUI
At WWDC25 we launched a new type of Lab event for the developer community - Group Labs. A Group Lab is a panel Q&A designed for a large audience of developers. Group Labs are a unique opportunity for the community to submit questions directly to a panel of Apple engineers and designers. Here are the highlights from the WWDC25 Group Lab for SwiftUI. What's your favorite new feature introduced to SwiftUI this year? The new rich text editor, a collaborative effort across multiple Apple teams. The safe area bar, simplifying the management of scroll view insets, safe areas, and overlays. NavigationLink indicator visibility control, a highly requested feature now available and back-deployed. Performance improvements to existing components (lists, scroll views, etc.) that come "for free" without requiring API adoption. Regarding performance profiling, it's recommended to use the new SwiftUI Instruments tool when you have a good understanding of your code and notice a performance drop after a specific change. This helps build a mental map between your code and the profiler's output. The "cause-and-effect graph" in the tool is particularly useful for identifying what's triggering expensive view updates, even if the issue isn't immediately apparent in your own code. My app is primarily UIKit-based, but I'm interested in adopting some newer SwiftUI-only scene types like MenuBarExtra or using SwiftUI-exclusive features. Is there a better way to bridge these worlds now? Yes, "scene bridging" makes it possible to use SwiftUI scenes from UIKit or AppKit lifecycle apps. This allows you to display purely SwiftUI scenes from your existing UIKit/AppKit code. Furthermore, you can use SwiftUI scene-specific modifiers to affect those scenes. Scene bridging is a great way to introduce SwiftUI into your apps. This also allows UIKit apps brought to Vision OS to integrate volumes and immersive spaces. It's also a great way to customize your experience with Assistive Access API. Can you please share any bad practices we should avoid when integrating Liquid Glass in our SwiftUI Apps? Avoid these common mistakes when integrating liquid glass: Overlapping Glass: Don't overlap liquid glass elements, as this can create visual artifacts. Scrolling Content Collisions: Be cautious when using liquid glass within scrolling content to prevent collisions with toolbar and navigation bar glass. Unnecessary Tinting: Resist the urge to tint the glass for branding or other purposes. Liquid glass should primarily be used to draw attention and convey meaning. Improper Grouping: Use the GlassEffectContainer to group related glass elements. This helps the system optimize rendering by limiting the search area for glass interactions. Navigation Bar Tinting: Avoid tinting navigation bars for branding, as this conflicts with the liquid glass effect. Instead, move branding colors into the content of the scroll view. This allows the color to be visible behind the glass at the top of the view, but it moves out of the way as the user scrolls, allowing the controls to revert to their standard monochrome style for better readability. Thanks for improving the performance of SwiftUI List this year. How about LazyVStack in ScrollView? Does it now also reuse the views inside the stack? Are there any best practices for improving the performance when using LazyVStack with large number of items? SwiftUI has improved scroll performance, including idle prefetching. When using LazyVStack with a large number of items, ensure your ForEach returns a static number of views. If you're returning multiple views within the ForEach, wrap them in a VStack to signal to SwiftUI that it's a single row, allowing for optimizations. Reuse is handled as an implementation detail within SwiftUI. Use the performance instrument to identify expensive views and determine how to optimize your app. If you encounter performance issues or hitches in scrolling, use the new SwiftUI Instruments tool to diagnose the problem. Implementing the new iOS 26 tab bar seems to have very low contrast when darker content is underneath, is there anything we should be doing to increase the contrast for tab bars? The new design is still in beta. If you're experiencing low contrast issues, especially with darker content underneath, please file feedback. It's generally not recommended to modify standard system components. As all apps on the platform are adopting liquid glass, feedback is crucial for tuning the experience based on a wider range of apps. Early feedback, especially regarding contrast and accessibility, is valuable for improving the system for all users. If I’m starting a new multi-platform app (iOS/iPadOS/macOS) that will heavily depend on UIKit/AppKit for the core structure and components (split, collection, table, and outline views), should I still use SwiftUI to manage the app lifecycle? Why? Even if your new multi-platform app heavily relies on UIKit/AppKit for core structure and components, it's generally recommended to still use SwiftUI to manage the app lifecycle. This sets you up for easier integration of SwiftUI components in the future and allows you to quickly adopt new SwiftUI features. Interoperability between SwiftUI and UIKit/AppKit is a core principle, with APIs to facilitate going back and forth between the two frameworks. Scene bridging allows you to bring existing SwiftUI scenes into apps that use a UIKit lifecycle, or vice versa. Think of it not as a binary choice, but as a mix of whatever you need. I’d love to know more about the matchedTransitionSource API you’ve added - is it a native way to have elements morph from a VStack to a sheet for example? What is the use case for it? The matchedTransitionSource API helps connect different views during transitions, such as when presenting popovers or other presentations from toolbar items. It's a way to link the user interaction to the presented content. For example, it can be used to visually connect an element in a VStack to a sheet. It can also be used to create a zoom effect where an element appears to enlarge, and these transitions are fully interactive, allowing users to swipe. It creates a nice, polished experience for the user. Support for this API has been added to toolbar items this year, and it was already available for standard views.
Topic: UI Frameworks SubTopic: SwiftUI
1
0
1.2k
Jun ’25
Live Q&A Summary - SwiftUI foundations: Build great apps with SwiftUI
Here’s a recap of the Live Q&A for SwiftUI foundations: Build great apps with SwiftUI. If you participated and asked questions, thank you for coming and participating! If you weren’t able to join us live we hope this recap is useful Where can I watch the VOD? Is the sample code “Wishlist” that was shown available for download? You can view the replay of the entire event here https://www.youtube.com/watch?v=Z3vloOtZLkQ The sample code for the Wishlist app will be made available in the coming weeks on the Apple Developer website, we'll send an update via email when it is available. What are the best practices when it comes to building complex navigations in SwiftUI? The developer website has documentation on navigation style best practices. Explore navigation basics like NavigationStack and TabView to get a ground-up understanding. For documentation on navigation APIs see Navigation. How can I integrate UIKit with my SwiftUI app? What about adding SwiftUI into my UIKit app? See UIKit integration: Add UIKit views to your SwiftUI app, or use SwiftUI views in your UIKit app. Both UIKit and SwiftUI provide API to show a view hierarchy of the other. For UIKit to SwiftUI, you would use UIViewControllerRepresentable. For SwiftUI to UIKit, you would use UIHostingController. Landmarks: Interfacing with UIKit walks you through step by step how to implement UIKit in SwiftUI with UIViewControllerRepresentable, and this WWDC22 video demonstrates UIHostingController, for those that want to add SwiftUI to their UIKit. Does Wishlist feature a new iOS 26 font? How can I add custom fonts and text of my app? We’re glad to hear many of you liked wide text shown in Wishlist, however, It is the default system font with some light SwiftUI styling! Check it out for yourself in the sample code when made available, and you can learn more about customizing fonts and text by seeing Font and Applying custom fonts to text. Does Xcode have a dependency graph we can use to optimize our SwiftUI Views? Xcode comes with Instruments. Instruments is the best way to figure out what is causing excessive updates and other issues with performance. That link provides direct tutorials and resources for how to use and understand. Previews also have many useful tools for analyzing SwiftUI views, for more info see Previews in Xcode Check out this video from our latest WWDC Optimize SwiftUI performance with Instruments for information on how to use Instruments to profile and optimize your app with real-world applications If you still have questions, Check out the Instruments section of these forums and create a post so the community has the opportunity to help guide you. Are there UI debugging tools to help diagnose layout issues? Yes, Xcode also features a View Debugger located by selecting the View Debug Hierarchy, pictured below. Use the View Debugger to capture and inspect your view hierarchy, identifying which views affect window sizing. The SwiftUI Inspector also lets you examine view frames and layout behavior. See Diagnosing issues in the appearance of a running app to learn about debugging visual and layout issues. As an absolute beginner, what would be the first go-to step to go for training? Do I need prior knowledge of frameworks to get started with SwiftUI? A great place to learn how to develop for Apple platforms is with Pathways! Many developers start with Develop in Swift tutorials, which exposes you to several frameworks while teaching you the basics of SwiftUI. When you're ready to take your learning further, you can read the documentation for the specific frameworks that interest you at https://developer.apple.com/documentation/.
Topic: UI Frameworks SubTopic: SwiftUI
2
0
77
4d
What is the state of EventKit going forward?
I'm building an app that heavily relies on EKEventStore for calendar and reminder integration. The API is simple - and limited. Change notifications amount to "something changed, you'd better refetch everything you care about." There's no way to know whether the calendar was updated while your app was closed or backgrounded. EKEvents and EKReminders don't trigger SwiftUI view updates, so you end up shunting them into your own observable state and keeping the two in sync. My app is fairly complex rendering-wise, and I lament being locked into treating EKEventStore as a first-class citizen of my view and data layer. It makes everything clunkier, essentially shuts the door on modern features like undo/redo, and makes integrating with other calendar providers that much harder. I'm exploring a custom SwiftData DataStore ↔ EKEventStore sync engine, but this is no easy task. There are still many unknowns I'd need to spike out before I can even attempt a proper implementation. Still, I'm curious - is this something being actively worked on behind the scenes? Will we see a more modern, observable, SwiftUI-native EventKit integration in the future?
1
0
21
12m
Query with predicate in child view running too frequently.
I'm trying to determine if this is "expected" swiftui behavior or an issue with SwiftUI/Data which needs a feedback request... When a child view has a Query containing a filter predicate, the query is run with each and every edit of the parent view, even when the edit has no impact on the child view (e.g. bindings not changing). In the example below, ContentView has the TextField name, and while data is being entered in it, causes the Query in AddTestStageView to be run with each character typed, e.g. 30 characters result in 30 query executions. (Need "-com.apple.CoreData.SQLDebug 1" launch argument to see SQL output). Removing the filter predicate from the query and filtering in ForEach prevents the issue. In my actual use case, the query has a relatively small result set (<100 rows), but I can see this as a performance issue with the larger result sets. xcode/ios: 26.2 Repro example code: import SwiftUI import SwiftData // Repro to Query filter issue in child view running multiple time unexpectedly // Need "-com.apple.CoreData.SQLDebug 1" launch argument set to see SQL console output. @main struct ReproViewQueryMultipleRunningsApp: App { var body: some Scene { WindowGroup { ContentView() } .modelContainer(DataManager.shared.sharedModelContainer()) } } @Model final class TestStageClass { var id: UUID = UUID() var name: String = "" var isActive: Bool = true var displayOrder: Int = 0 init(name: String, isActive: Bool, displayOrder: Int) { self.name = name self.isActive = isActive self.displayOrder = displayOrder } } struct ContentView: View { @Environment(\.modelContext) var modelContext @State private var name: String = "" @State private var selectedTestStage: TestStageClass = DataManager.shared.getFirstTestStageClass() var body: some View { VStack (spacing: 20) { TextField("Name", text: $name) AddTestStageView(selectedTestStage: $selectedTestStage) } .frame(height: 200) } } #Preview("Sample Data") { ContentView() .modelContainer(DataManager.shared.sharedModelContainer()) } struct AddTestStageView: View { @Environment(\.modelContext) var modelContext @Binding var selectedTestStage: TestStageClass // MARK: - ISSUE LOCATION /// Using this Query with filter causes it to be run after each editing on parent view - such as each letter when editing a name. @Query(filter: #Predicate<TestStageClass> { $0.isActive }) private var testStageClasses: [TestStageClass] /// Using this query doesn't have the issue, then need filter in ForEach. // @Query() private var testStageClasses: [TestStageClass] var body: some View { Picker("stage", selection: $selectedTestStage) { // filter and sort here does not affect issue with above Query predicate filter. ForEach(testStageClasses.filter(\.isActive).sorted(by: { $0.displayOrder < $1.displayOrder } ), id: \.id) { stage in Text("\(stage.name)") .tag(stage) } } } } class DataManager { static let shared = DataManager() private var modelContainer: ModelContainer? = nil public func sharedModelContainer(inMemory: Bool = false) -> ModelContainer { let schema = Schema([TestStageClass.self]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: inMemory) do { self.modelContainer = try ModelContainer(for: schema, configurations: [modelConfiguration]) checkDataExists() return self.modelContainer! } catch { fatalError("Could not create sharedModelContainer. Schema:\(schema.entities.map(\.name)), \((modelConfiguration.isStoredInMemoryOnly) ? "in memory only" : "in disk"):\n\(error.localizedDescription)") } } private func checkDataExists() { let mainContext = self.modelContainer!.mainContext print("checkDataExists") do { let classData: [TestStageClass] = try mainContext.fetch(FetchDescriptor<TestStageClass>()) if classData.isEmpty { mainContext.insert(TestStageClass(name: "Beginning", isActive: true, displayOrder: 0)) mainContext.insert(TestStageClass(name: "Second Middle", isActive: false, displayOrder: 2)) mainContext.insert(TestStageClass(name: "Middle", isActive: true, displayOrder: 1)) mainContext.insert(TestStageClass(name: "End", isActive: true, displayOrder: 3)) } if mainContext.hasChanges { try? mainContext.save() print("Added Default Data for TestStageClass") } } catch { fatalError("Failed to get item count for TestStageClass: \(error.localizedDescription)") } } func getFirstTestStageClass() -> TestStageClass { let mainContext = self.modelContainer!.mainContext var tmp: TestStageClass? do { let classData: [TestStageClass] = try mainContext.fetch(FetchDescriptor<TestStageClass>()) tmp = classData.sorted(by: {$0.displayOrder < $1.displayOrder }).first } catch { fatalError("getFirstTestStageClass: \(error.localizedDescription)") } return tmp! } } Thanks, Steve
1
0
53
19h
Liquid Glass Button animating when behind a view when `.interactive()` modifier is applied
When using the .glassEffect modifier on a button in swiftui combined with the .interactive() modifier, the button continues to show the interactive animation even when it’s covered by another element. Example: ZStack { Button { print("Button overlayed by ZStack") // Does not trigger, but interactive animation still plays } label: { image } .glassEffect(.regular.interactive()) Rectangle().fill(.black.opacity(0.7)) } This occurs with overlays, ZStacks, and even if the overlay is a button. Example below: EDIT: It seems like rocketsim's gif recording doesnt show the bug for some reason... really strange... Edit 2: reuploaded gif, recorded as mp4 and converted to gif seems to have worked... Feedback ID: FB22054300 I've attached this sample app to my feedback ticket to help with debugging the issue. It doesn't look like I can share it in this post though.
1
1
33
1d
"NavigationLink in List incorrectly highlights when destination value exists in NavigationStack path"
In SwiftUI, when using NavigationStack with a path binding containing multiple instances of the same (or many with navigationPath()) model type (since model type are class type, this issue might occur on instances of class type too), any NavigationLink in a detail view that leads to a value already present anywhere in the navigation stack (which is in the path binding) will appear incorrectly highlighted upon the view's initial appearance. This bug seems manifests specifically when the links are contained within a List. The highlighting is inconsistent - only the earliest appended value in path has link in each section displays as pressed, while links to other value appear normal. Below is a simple code to reproduce the bug. import SwiftUI import SwiftData // Simple model @available(iOS 17, *) @Model class Item { var id = UUID() var name: String var relatedItems: [Item] init(name: String = "", relatedItems: [Item] = []) { self.name = name self.relatedItems = relatedItems } } // MARK: - Bug Reproducer @available(iOS 17, *) struct BugReproducerView: View { @State private var path: [Item] = [] let items: [Item] init() { let item1 = Item(name: "Item 1", relatedItems: []) let item2 = Item(name: "Item 2", relatedItems: [item1]) item1.relatedItems = [item2] self.items = [item1, item2] } var body: some View { NavigationStack(path: $path) { List(items) { item in NavigationLink(item.name, value: item) } .navigationTitle("Items") .navigationDestination(for: Item.self) { item in DetailView(item: item) } } } } // MARK: - Detail View with Bug @available(iOS 17, *) struct DetailView: View { let item: Item var body: some View { List { Section("Info") { Text("Selected: \(item.name)") } if !item.relatedItems.isEmpty { Section("Related") { ForEach(item.relatedItems) { related in NavigationLink(related.name, value: related) } } } } .navigationTitle(item.name) } } #Preview { if #available(iOS 17, *) { BugReproducerView() } else { } }
0
0
19
1d
TimelineView using ExplicitTimelineSchedule ignores last date?
Hi, everyone. I'm trying my first TimelineView with an explicit schedule, but my attempt – and even the simple example from the documentation – doesn't seem to work as documented. Here's what the documentation says an explicit schedule does: The timeline view updates its content on exactly the dates that you specify, until it runs out of dates, after which it stops changing. And it gives this example: let dates = [ Date(timeIntervalSinceNow: 10), // Update ten seconds from now, Date(timeIntervalSinceNow: 12), // and a few seconds later. ] struct MyView: View { var body: some View { TimelineView(.explicit(dates)) { context in Text(context.date.description) } } } There are stipulations about what the view – which always displays some version of its content body – will do given only past or future dates, but it seems clear we should expect the view in this example to redraw at least once after it appears. Here's the rest of the discussion from the documentation with my comments after testing what's stated: If the dates you provide are in the past, the timeline view updates exactly once with the last entry. That seems true, considering the "update" to be the initial draw. If you only provide dates in the future, the timeline view renders with the current date until the first date arrives. Not exactly: it looks the "date" property of the initial render is the (future) date of the first schedule entry, even though it's drawn early. When the first date does arrive, the body closure doesn't seem to be called. Only on the next date, if there is one, is it called again. If you provide one or more dates in the past and one or more in the future, the view renders the most recent past date, refreshing normally on all subsequent dates. That also seems correct, except… … that in every scenario, the final date entry seems to be ignored completely! In other words, unless all date entries are in the past, the Timeline View stops before it runs out of dates. That documented example from the start, which we expect to redraw at least once after it appears? When I test it in a Playground, it appears, but doesn't redraw at all! So, that's my main point of confusion after experimenting with TimelineView for the first time. I can achieve my own goal by appending an extra entry to my explicit schedule – even appending an entry identical to the previous "final" entry seems to work – but naturally that leaves me unclear about why I need to. If anyone can tell me what I'm not understanding, I'd be grateful.
4
2
821
2d
SwiftUI Link view corrupts destination URLs when using a leading-zero padded IPv4 address.
There appears to be a bug in Link with IPv4 addresses with padding in the second octet, on macOS and iOS both. struct LinkViewBug: View { let works = URL(string: "http://172.16.1.1")! let alsoWorks = URL(string: "http://172.16.001.001")! let doesntWork = URL(string: "http://172.016.001.001")! let alsoDoesntWork = URL(string: "http://172.016.1.1")! var body: some View { // destination -> http://172.16.1.1 Link(works.formatted(), destination: works) Link(alsoWorks.formatted(), destination: alsoWorks) // destination -> http://172.14.1.1 ? Link(doesntWork.formatted(), destination: doesntWork) Link(alsoDoesntWork.formatted(), destination: alsoDoesntWork) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
18
2d
TabView with .page style vibrates and reloads content during sheet detent drag
FeedBack Id: FB22031397 (Demo proj Attached to Feedback) Description: When a TabView using .page tabViewStyle is placed inside a sheet configured with multiple presentationDetents, dragging the sheet handle to resize between detents causes the TabView to re-render all its pages on every frame of the drag gesture. This results in visible content vibration, scroll position jumping, and tab content flashing during the drag. The issue is fully reproducible with the attached minimal demo project. Steps to Reproduce: Run the attached TabViewSheetVibrationDemo.swift on any iOS device or simulator Tap "Open Sheet" on the main screen Swipe left to any tab Scroll down inside the tab so content is not at the top Grab the sheet drag indicator at the top and slowly drag upward or downward to resize between medium and large detent Observe the tab content while dragging Expected Results: The TabView page content should remain completely stable during sheet resize. Scroll positions should be preserved and no re-rendering should occur because the underlying data has not changed. The sheet should resize smoothly while tab content stays still. Actual Results: The TabView re-renders all pages on every frame of the drag gesture. This causes: Visible content vibration and jitter while dragging the sheet handle Scroll position jumping back toward the top mid-drag Tab content flashing as pages are recreated The problem is proportional to drag speed — slower drags show a stuttering effect, faster drags cause a full content flash Configuration: All Xcode including beta iOS 26 (also reproduced on iOS 16, iOS 17 and iOS 18) Reproducible on both Simulator and real device Affects iPhone and iPad
0
0
27
2d
In SwiftUI for macOS, is there an equivalent to NSControl.BorderShape?
In macOS 26, there is a new property on NSControl called .borderShape. The WWDC 2025-310 video says it can be used to "Override preferred shape of control to suit your design." and that it's available on NSButton, NSPopUpButton and NSSegmentedControl. Is there an equivalent to that property for SwiftUI? For example, given the following SwiftUI code: Button("Eject") { } .borderShape(...) <-- ? How can I apply a .borderShape that would match those on controls created in AppKit? I'm aware that SwiftUI offers a plethora of ways to custom design a button such that it can have rounded corners, but I'm interested in this particular property so that SwiftUI buttons and AppKit buttons in the same app have the same look-and-feel.
1
0
39
2d
Do SwiftUI Segmented Controls on macOS 26 support the icon and title label style?
On macOS 26.3, Xcode 26.3, why does a labelStyle of titleAndIcon not show both the title and the icon of a label? The label styles iconOnly and titleOnly behave as expected. Picker("Label Demo", selection: $selectedItem) { Label { Text("File") } icon: { Image(systemName: "doc") } Label { Text("Folder") } icon: { Image(systemName: "folder") } } .labelStyle(.titleAndIcon) .pickerStyle(.segmented) Note that there is no icon shown. Placing the .labelStyle modifier in different places has no effect. The icon is correctly shown when the labelStyle is set to .iconOnly. An NSSegmentedControl created with AppKit and presented in an NSViewRepresentable does correctly show titles and icons if configured appropriately. Tested on: macOS 26.3 (25D125) Xcode 26.3 (17C519) A brand new SwiftUI "macOS App" project.
2
0
48
2d
Button in ToolbarItem is not completely tapable on iOS 26
I have an icon button in toolbar but only the icon is triggering tap events while outside icon button gives tap feedback but event is not firing. Code: ToolbarItem(placement: .navigationBarTrailing) { Button(action: toggleBookmark) { Image(systemName: isBookmarked ? "bookmark.fill" : "bookmark") .resizable() .aspectRatio(0.8, contentMode: .fit) .frame(width: 20, height: 20) } } Here toggleBookmark function is only called if I click on Image but not if I click outside image but on the circular button that appears on iOS 26. See this screen recording.
Topic: UI Frameworks SubTopic: SwiftUI
4
1
113
3d
CarPlay: Can third-party audio apps add a Search/Siri button next to the Now Playing button like Apple Music?
Hi, In Apple Music on CarPlay, there is a Search button shown next to the Now Playing (NPS) button in the top navigation bar. Tapping this Search button activates Siri voice search. I want to understand: Does CarPlay allow third-party audio apps to add a similar Search button in the top bar (next to the Now Playing button)? Which can be used to trigger Siri from the screen UI (not steering-wheel button or “Hey Siri”)? Is there any supported approach for screen-based Siri activation other than the guidance here: https://developer.apple.com/documentation/carplay/cplisttemplate#Integrating-Siri-Into-Your-Template-App Basically, is the Apple Music search/Siri button a publicly available CarPlay capability, or is it system-reserved?
0
0
31
3d
Performance degradation and redraw loops when syncing SwiftUI Charts with custom AxisMarks
I am reporting a reproducible performance issue in iOS 18.6 where synchronizing the scroll position of two Chart views via chartScrollPosition(id:) causes a complete redraw loop when custom AxisMarks are used. This occurs even when the axis marks are technically "hidden," leading to significant frame drops and stuttering on modern hardware like the iPhone 15. Environment Device: iPhone 15 OS: iOS 18.6 (22G86) Frameworks: SwiftUI, Swift Charts, Observation The Issue When using a shared @Observable state to sync two charts, the scrolling is fluid only if the axes are at their default settings. As soon as a custom AxisMarks block is added to either chart, the following behavior is observed: Diffing Failure: The framework appears unable to maintain the identity of the axis components during the scroll update. Redraw Loop: Instead of an incremental scroll translation, the diffing algorithm triggers a full reload/re-render of both charts on every scroll offset change. Impact: CPU spikes to 100% and the UI becomes unresponsive. This happens even if the custom AxisMarks is used solely to hide the axis (e.g., AxisMarks { _ in }), suggesting the issue is with the custom declaration itself rather than the complexity of the marks being rendered. Steps to Reproduce Create two Chart views in a VStack. Bind both to a single @Observable property using .chartScrollPosition(id: $state.pos). Add any .chartXAxis { AxisMarks(...) { ... } } modifier. Scroll either chart; observe the stuttering. import SwiftUI import Charts import Observation @Observable class ChartState { var scrollPos: Date = .now } struct PerformanceBugView: View { @State private var state = ChartState() var body: some View { VStack { Chart(data) { ... } .chartScrollPosition(id: $state.scrollPos) .chartXAxis { // This custom mark triggers the performance issue AxisMarks { _ in AxisValueLabel() } } Chart(data) { ... } .chartScrollPosition(id: $state.scrollPos) } } } Questions for the Community/Apple Engineers: Is there a way to provide a stable identifier to AxisMarks to prevent them from being treated as "new" during a scroll update? Why does even an empty AxisMarks block (used for hiding) trigger a layout invalidation that standard axes do not? Are there internal optimizations for chartScrollPosition that are bypassed when the axis layout is customized?
0
0
21
3d
How to delete a row from a table
To display rows and columns of data in a nice layout like a spreadsheet I use a table like the code here .. Table(array) { TableColumn("Ticker", value: \\.ticker) TableColumn("Other", value: \.other) } To delete a row from the table the advice is to use a ForEach loop. Since I don’t use a ForEach loop, how do I delete rows from the table ? With this code there is no way to attach a .onDelete modifier or a Button Any advice would be much appreciated Thank you
Topic: UI Frameworks SubTopic: SwiftUI
1
0
34
4d
Does anyone know how to prevent Liqud Glass from stretching when elements with the glassEffect are dragged?
When making an element with .glassEffect(.clear.interactive()) draggable, it stretches as it moves. It seems like it's meant to stretch as you move your finger away from the element, but it doesn't make sense if the element is following your finger as you drag it. Is this a bug, or is there a way to disable this behavior without removing the other "interactive" animations? P.S. The shiny border around the elements seems to be a rounded rectangle or capsule, but the actual element's shape seems to be stretched. That also appears to be a bug.
0
0
47
5d
iOS 26.3: Memory crash with @AppStorage and view transitions
I'm experiencing consistent memory crashes in iOS 26.3 (23D127) when using @AppStorage with view transitions. Environment: Device: iPhone 17 Pro Max iOS: 26.3 (23D127) Xcode: 26.2 (17C52) Issue: App crashes with "Terminated due to memory issue" when: Using @AppStorage to manage state Calling UserDefaults.set() in completion handler Transitioning to new view based on changed state Workaround: Using @State instead of @AppStorage prevents crash. Feedback: FB############ (your number) Has anyone else experienced this? Is this a known issue in iOS 26?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
33
6d
.navigationDestination(isPresented hangs after reboot in watchOS when destination view contains @Environment(\.dismiss)
.navigationDestination(isPresented) hangs after reboot (when called within 2 minutes of reboot) in watchOS when destination view contains @Environment(.dismiss). Feedback: FB21077151 Second button hangs after reboot. Hangs in watchOS 26.0 and 26.4 on a physical device. struct ContentView: View { @State var presentView1 : Bool = false @State var presentView2 : Bool = false var body: some View { NavigationStack { VStack { Button("Show View 1") { presentView1.toggle() } Button("Show View 2") { presentView2.toggle() } } .navigationDestination(isPresented: $presentView1, destination: {TestView1()}) .navigationDestination(isPresented: $presentView2, destination: {TestView2()}) } } } struct TestView1: View { var body: some View { Text("View 1") } } struct TestView2: View { @Environment(\.dismiss) var dismiss var body: some View { Text("View 2") } }
2
0
78
6d