Explore the various UI frameworks available for building app interfaces. Discuss the use cases for different frameworks, share best practices, and get help with specific framework-related questions.

All subtopics
Posts under UI Frameworks topic

Post

Replies

Boosts

Views

Created

touchesEnded: not triggered on newer iOS when view is inside UIScrollView (was working on iOS 18)
Hi everyone, I’m facing an issue with touch handling on newer iOS versions. I have a custom view controller implemented in Objective-C that overrides touchesEnded:. The same code works correctly on iOS 18, but on newer iOS versions (tested on iOS 26), touchesEnded: is no longer being triggered. Important observations: touchesBegan: is triggered. touchesEnded: is NOT triggered. touchesCancelled: is also NOT triggered. No code changes were made between iOS 18 and iOS 26. Same code, same sample works fine in iOS18 device but not in iOS26 device Questions: Has gesture arbitration behavior changed in recent iOS 26 versions when views are inside UIScrollView? Any clarification on whether this is intended behavior or a regression would be greatly appreciated. Thank you.
Topic: UI Frameworks SubTopic: UIKit
6
0
267
1w
Access Relationship value from deleted model tombstone in SwiftData.
I’m developing an app using SwiftData. In my app, I have two models: User and Address. A user can have multiple addresses. I’m trying to use SwiftData History tracking to implement some logic when addresses are deleted. Specifically, I need to determine which user the address belonged to. From the documentation, I understand that you can preserve attributes from deleted models in a tombstone object using @Attribute(.preserveValueOnDeletion). However, this isn’t working when I try to apply this to a relationship value. Below is a simplified example of my attempts so far. I suspect that simply adding @Attribute(.preserveValueOnDeletion) to a relationship isn’t feasible. If that’s indeed the case, what would be the recommended approach to identify the user associated with an address after it has been deleted? Thank you. @Model class User { var name: String @Relationship(deleteRule: .cascade, inverse: \Address.user) var addresses: [Address] = [] init(name: String) { self.name = name } } @Model class Address { var adress1: String var address2: String var city: String var zip: String @Attribute(.preserveValueOnDeletion) var user: User? init(adress1: String, address2: String, city: String, zip: String) { self.adress1 = adress1 self.address2 = address2 self.city = city self.zip = zip self.user = user } } for transaction in transactions { for change in transaction.changes { switch change { case .delete(let deleted): if let deleted = deleted as? any HistoryDelete<Address> { if let user = deleted.tombstone[\.user] { //this is never executed } } default: break } } }
1
0
84
1w
Crash in SwiftUICore SDFStyle.distanceRange.getter
I've been receiving crash reports about a crash in SDFStyle.distanceRange.getter. I haven't been able to reproduce this, and users haven't given me much information about the circumstances or can't reliably reproduce this either. Googling didn't give any results. I'm happy for any pointers in the right direction. All reports have been on iOS 26 so far. 2026-03-02_23-35-03.7381_+0800-93830d0f537cfb381b42a7e9812953d772adfe64.crash
Topic: UI Frameworks SubTopic: SwiftUI
1
0
209
1w
TextKit 2 + SwiftUI (NSViewRepresentable): NSTextLayoutManager rendering attributes don’t reliably draw/update
I’m embedding an NSTextView (TextKit 2) inside a SwiftUI app using NSViewRepresentable. I’m trying to highlight dynamic subranges (changing as the user types) by providing per-range rendering attributes via NSTextLayoutManager’s rendering-attributes mechanism. The issue: the highlight is unreliable. Often, the highlight doesn’t appear at all even though the delegate/data source is returning attributes for the expected range. Sometimes it appears once, but then it stops updating even when the underlying “highlight range” changes. This feels related to SwiftUI - AppKit layout issue when using NSViewRepresentable (as said in https://developer.apple.com/documentation/swiftui/nsviewrepresentable). What I’ve tried Updating the state that drives the highlight range and invalidating layout fragments / asking for relayout Ensuring all updates happen on the main thread. Calling setNeedsDisplay(_:) on the NSViewRepresentable’s underlying view. Toggling the SwiftUI view identity (e.g. .id(...)) to force reconstruction (works, but too expensive / loses state). Question In a SwiftUI + NSViewRepresentable setup with TextKit 2, what is the correct way to make NSTextLayoutManager re-query and redraw rendering attributes when my highlight ranges change? Is there a recommended invalidation call for TextKit 2 to trigger re-rendering of rendering attributes? Or is this a known limitation when hosting NSTextView inside SwiftUI, where rendering attributes aren’t reliably invalidated? If this approach is fragile, is there a better pattern for dynamic highlights that avoids mutating the attributed string (to prevent layout/scroll jitter)?
3
0
197
1w
UIScreen.isCaptured and sceneCaptureState report inactive while system screen recording continues when Live Activity is expanded
Hi, I’m trying to reliably detect when system screen recording finishes, and I’m observing behavior that I don’t fully understand when a Live Activity is expanded via Dynamic Island. Environment Devices: iPhone 16 Pro iOS: 26.2 Xcode: 26.2 Using UIScreen.isCaptured and UIWindowScene.sceneCaptureState Implementation: I observe capture state like this: private var observation: NSKeyValueObservation? func startObserving() { observation = UIScreen.main.observe(\.isCaptured, options: [.new]) { _, change in print("isCaptured:", change.newValue ?? false) } } I also check: window.traitCollection.sceneCaptureState Steps to Reproduce Start system screen recording from Control Center. Confirm UIScreen.main.isCaptured == true. Expand a Live Activity via the Dynamic Island (e.g. timer or call). Observe capture state values while the Live Activity UI is expanded. Observed Behavior While screen recording is still active: UIScreen.main.isCaptured becomes false sceneCaptureState becomes .inactive This state persists while the recording Live Activity is expanded The system recording indicator remains visible The device continues recording Expected Behavior (or Clarification Needed) My understanding was that UIScreen.isCaptured indicates whether the device screen is currently being captured (e.g. screen recording or mirroring). However, this behavior suggests that both isCaptured and sceneCaptureState reflect whether the current scene is part of the capture surface, rather than whether device-level recording is active. Is this the intended behavior when system-owned surfaces (such as expanded Live Activities) are promoted above the app’s scene? If so: Is there any supported way to reliably detect device-level screen recording state (as opposed to scene-level capture participation), in order to trigger logic when recording finishes? Thank you for any clarification.
Topic: UI Frameworks SubTopic: UIKit
0
0
43
1w
How do you make a resizable segmented control in SwiftUI for macOS?
In SwiftUI for macOS, how do I configure a Picker as a segmented control to have a flexible width? This design pattern is present in Xcode 26 at the top of the sidebar and inspector panel. I can't figure out the combination of view modifiers to achieve a similar look. import SwiftUI struct ContentView: View { @State private var selection = 0 var body: some View { VStack { Picker("", selection: $selection) { Image(systemName: "doc") Image(systemName: "folder") Image(systemName: "gear") Image(systemName: "globe") .frame(maxWidth: .infinity) // Doesn't do anything. } .labelsHidden() .pickerStyle(.segmented) .frame(maxWidth: .infinity) // Doesn't affect segment sizes. Spacer() } } } I want the entire Picker to fill the width and for each segment to be of equal widths. How? In AppKit I would use AutoLayout for the flexible width and NSSegmentedControl.segmentDistribution for the segment widths. Is there a SwiftUI equivalent? macOS 26 / Xcode 26.3
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
82
1w
Active Quicklook extension is ignored
When you have multiple Apps on the Mac which all provide Quicklook extensions for the same file type, then I would assume that if I activate one of these Quicklook extensions in the system settings, this one would be used. But this doesn't seem to be the case. It looks like the macOS just looks the very first extension it can find for a certain file type, and if this Quicklook extension is switched off, the file can not be previewed anymore. The macOS just doesn't bother to look for the other existing quicklook extension for this file, even if this other is enabled. The only option right now to get this other extension to be used by the system would be to completely delete the first App, so its extension is deleted as well. Is this really the way how it is supposed to work? How can this be fixed? Can I tell my users something else than "just delete the other App"?
0
0
91
1w
Detect closing of tab (NSWindowTab) in WindowGroup
I have a SwiftUI app displaying tabbed windows (as NSWindowTab) in a WindowGroup: import SwiftUI @main struct TabTestApp: App { var body: some Scene { WindowGroup{ ContentView() // Hasn't any content of relevance to this question. }.commands{ CommandGroup(after: .newItem) { Button("New Tab") { guard let currentWindow = NSApp.keyWindow, let windowController = currentWindow.windowController else { return } windowController.newWindowForTab(nil) guard let newWindow = NSApp.keyWindow else { return } if currentWindow != newWindow { currentWindow.addTabbedWindow(newWindow, ordered: .above) } }.keyboardShortcut(.init("t", modifiers: [.command])) } } } } Is there a way to detect the closing of one or multiple tabs, e.g. when the user clicks on the tab bar's "Close Other Tabs" option or pushes CMD + W in order to ask the user whether he or she wants to save changes? What I've tried to no avail: Intercept windowWillClose👉Won't be called if a single tab within a window is closed (but only once the last tab of a window is closed). Handling onDissapear()👉Doesn't work since the closing cannot be cancelled. Using DocumentGroup 👉Doesn't work since the app in question isn't about documents (i.e., files which are stored externally), but about data that's stored in a database. Many thanks! Related threads: Preserve all tabs of last window on close. (Like Finder) Detect Close Window vs Close Tab
0
0
64
1w
CarPlay CPListImageRowItem causes Inverted Scrolling and Side Button malfunction
In my CarPlaySceneDelegate.swift, I have two tabs: The first tab uses a CPListImageRowItem with a CPListImageRowItemRowElement. The scroll direction is inverted, and the side button does not function correctly. The second tab uses multiple CPListItem objects. There are no issues: scrolling works in the correct direction, and the side button behaves as expected. Steps To Reproduce Launch the app. Connect to CarPlay. In the first tab, scroll up and down, then use the side button to navigate. In the second tab, scroll up and down, then use the side button to navigate. As observed, the scrolling behavior is different between the two tabs. Code Example: import CarPlay import UIKit class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate { var interfaceController: CPInterfaceController? func templateApplicationScene( _ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController ) { self.interfaceController = interfaceController downloadImageAndSetupTemplates() } func templateApplicationScene( _ templateApplicationScene: CPTemplateApplicationScene, didDisconnectInterfaceController interfaceController: CPInterfaceController ) { self.interfaceController = nil } private func downloadImageAndSetupTemplates() { let urlString = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRcYUjd1FYkF04-8Vb7PKI1mGoF2quLPHKjvnR7V4ReZR8UjW-0NJ_kC7q13eISZGoTCLHaDPVbOthhH9QNq-YA0uuSUjfAoB3PPs1aXQ&s=10" guard let url = URL(string: urlString) else { setupTemplates(with: UIImage(systemName: "photo")!) return } URLSession.shared.dataTask(with: url) { [weak self] data, _, _ in let image: UIImage if let data = data, let downloaded = UIImage(data: data) { image = downloaded } else { image = UIImage(systemName: "photo")! } DispatchQueue.main.async { self?.setupTemplates(with: image) } }.resume() } private func setupTemplates(with image: UIImage) { // Tab 1 : un seul CPListImageRowItem avec 12 CPListImageRowItemRowElement let elements: [CPListImageRowItemRowElement] = (1...12).map { index in CPListImageRowItemRowElement(image: image, title: "test \(index)", subtitle: nil) } let rowItem = CPListImageRowItem(text: "Images", elements: elements, allowsMultipleLines: true) rowItem.listImageRowHandler = { item, elementIndex, completion in print("tapped element \(elementIndex)") completion() } let tab1Section = CPListSection(items: [rowItem]) let tab1Template = CPListTemplate(title: "CPListImageRowItemRowElement", sections: [tab1Section]) // Tab 2 : 12 CPListItem simples let tab2Items: [CPListItem] = (1...12).map { index in let item = CPListItem(text: "Item \(index)", detailText: "Detail \(index)") item.handler = { _, completion in print("handler Tab 2") completion() } return item } let tab2Section = CPListSection(items: tab2Items) let tab2Template = CPListTemplate(title: "CPListItem", sections: [tab2Section]) // CPTabBarTemplate avec les deux tabs let tabBar = CPTabBarTemplate(templates: [tab1Template, tab2Template]) interfaceController?.setRootTemplate(tabBar, animated: true) } } Here is a quick video:
0
0
131
1w
"Searchable with .toolbarPrincipal incorrectly places search field at bottom instead of navigation bar"
When using .searchable with placement: .toolbarPrincipal inside a NavigationStack, the search field is incorrectly placed at the bottom of the view instead of the principal position where ToolbarPlacement.principal normally resides. This is confirmed by testing: a ToolbarItem with placement: .principal containing Text("Title") gets pushed away when the .searchable modifier is added, yet the search field still appears at the bottom rather than taking over the principal location as documented.
0
0
41
1w
Wrong appearance of decimalPad keyboard in dark mode
Hi. The following code causes UI mismatch on iOS26. Keyboard with type decimalPad and appearance as dark is displayed as popUp with wrong colors. Before iOS26 keyboard was regular with correct color scheme. Please advice either how to make the scheme correct or force to display regular keyboard instead of popup. class ViewController: UIViewController { @IBOutlet weak var textField: UITextField! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. textField.keyboardType = .decimalPad textField.keyboardAppearance = .dark view.backgroundColor = .darkGray } }
1
1
94
1w
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!
1
0
100
1w
Data Persistence not functioning upon refresh
Hello, I am attempting to implement a simple button that loads persistent data from a class (see below). Button("Reload Data") { while tableData2.isEmpty == false{ tableData2.remove(at: 0) } while tableView.isEmpty == false{ tableView.remove(at: 0) } //update if csvData.isEmpty == false{ for superRow in csvData[0].tableData2{ tableData2.append(superRow) } for supperRow in csvData[0].tableView{ tableView.append(supperRow) } print("Item at 0: \(csvData[0].tableData2[[0][0]])") print("\(tableData2[0][0])") } else { print("csvData is empty") } } This button DOES work to appropriately print the data stored at the printed location once loaded in initially. The problem is that it doesn’t work across app restarts, which is the whole point of the button. Below I will include the rest of the relevant code with notes: In contentView declaring the persistant variables: Query private var csvData: [csvDataPersist] Environment(\.modelContext) private var modelContext The simple class of data I’m storing/pulling to/from: @Model class csvDataPersist{ var tableView: [[String]] = [] var tableData2: [[String]] = [] init(tableView: [[String]], tableData2: [[String]]) { self.tableView = tableView self.tableData2 = tableData2 } } In (appname)App: I tried both locations of the model container but it didn’t seem to matter var body: some Scene { WindowGroup { ContentView() .modelContainer(for: csvDataPersist.self) } //.modelContainer(for: csvDataPersist.self) .modelContainer(sharedModelContainer) } How I’m attempting to save the data: let newCSVDataPersist = csvDataPersist(tableView: tableView, tableData2: tableData2) //modelContext.rollback() //for superrow in csvData.count{ // csvData[superrow].tableData2.removeAll() //} //modelContext.rollback() //csvData[0].tableData2.removeAll() //csvData[0].tableView.removeAll() if csvData.isEmpty == false { print("not empty, deleting prev data") modelContext.delete(csvData[0]) } else { print("it empty, load data.") } modelContext.insert(newCSVDataPersist) //try modelContext.save() Note that I’ve tried just about every combination of enabling and disabling the commented out lines. This is the part of the code I am the least confident in, but after trying for hours to troubleshoot on my own I would appreciate any input from the community. Something else that may be of note, in a previous attempt, upon a second startup, the terminal would print: "coredata: error: error: persistent history (random number) has to be truncated due to the following entities being removed: ( csvdatapersist )" Why is csvDataPersist getting removed? What is it getting removed by? Looking up this error was fruitless. Most sites instructed me to basically hard reset my simulators, clean the build, restart my computer, and try again. I've done all of these things about a hundred times at this point, with no results. Any help would be much appreciated!
3
0
88
1w
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
61
1w
navigationItem.titleView shifted left when leftBarButtonItem is nil in iOS 26
iOS 26 – navigationItem.titleView shifted left when leftBarButtonItem is nil Hi everyone, I’m encountering a layout issue on iOS 26 related to navigationItem.titleView positioning. What I’m Doing I’m hiding the default back button and removing the left bar button item: navigationItem.leftBarButtonItem = nil navigationItem.hidesBackButton = true navigationItem.setLeftBarButtonItems([], animated: true) Then I create a custom titleView with a specific width calculated as: Screen width minus the width of the two bar button items (left and right). let titleView = UIView(frame: CGRect(origin: .zero, size: sizeOfTitleView)) let titleLabel = UILabel(frame: CGRect(origin: .zero, size: sizeOfTitleView)) Expected Behavior On previous iOS versions, the titleView is perfectly centered in the navigation bar. Actual Behavior (iOS 26) On iOS 26, when leftBarButtonItem is nil, the titleView is pushed slightly to the left instead of being centered (see attached image). Question Has there been a change in UINavigationBar layout behavior in iOS 26? What is the correct way to ensure the titleView remains perfectly centered when there is no leftBarButtonItem? Any guidance would be appreciated. Thanks!
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
105
1w
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
76
1w
modifierFlags Monterey
Hello Using a MacBook Pro Intel with macOS 12.7.6 Monterey, I test in Objective-C an event for the option key but it is not working - (void)keyDown:(NSEvent *)event { printf("%s %p\n", __FUNCTION__, self); BOOL altFlag = [event modifierFlags] & NSEventModifierFlagOption; if (altFlag) { // UpdateClass printf("option pressed\n"); } else { printf("option not pressed\n"); } } The same in Swift works fine override func keyDown(with event: NSEvent) { if event.modifierFlags.contains(.option) { print("option pressed") } else { print("option NOT pressed") } } The Obj-C code works fine on a MacBook Air Tahoe 26.3 Any idea why it does not work on the macOS 12.7.6 Intel? Many Thanks Jean
2
0
131
1w
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.
2
1
144
1w
"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
45
1w