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

Activity

Cannot render ScrollView + VStack + ScrollPosition correctly scrolled initially
The following code works properly, ensuring the list is scrolled at the correct ID when first rendered: import SwiftUI struct DataItem: Identifiable { let id: Int let height: CGFloat init(id: Int) { self.id = id self.height = CGFloat.random(in: 100...300) } } struct ContentView: View { @State private var items = (0..<1000).map { DataItem(id: $0) } @State private var scrollPosition: ScrollPosition init() { let mid = 500 _scrollPosition = State(initialValue: .init(id: mid, anchor: .center)) } var body: some View { ScrollView { LazyVStack(spacing: 8) { ForEach(items) { item in Text("Item \(item.id)") .frame(height: item.height) .frame(maxWidth: .infinity) .background(.gray) } } .scrollTargetLayout() } .scrollPosition($scrollPosition, anchor: .center) } } However, if I change this to use VStack this ceases to work - the list begins rendered at the top of the list. The only way I can render it starting at the correct position is using side effects like onAppear or task, where I would update the scroll position. I have observed the following behavior on my iPhone 15 Pro/iOS 26. Is this a bug?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
34
5d
`onTapGesture` not triggered on `Map` views
When building with iOS 26 SDK beta 5 (23A5308f), onTapGesture is no longer being triggered on Map views. This appears to be a regression in beta 5 specifically, as this issue was not present in beta 4. How to reproduce Code The following code demonstrates the issue, as seen in the videos below. import MapKit import SwiftUI struct ContentView: View { @State private var location = CGPoint.zero var body: some View { Map() .onTapGesture { location in self.location = location } .safeAreaInset(edge: .bottom) { VStack(alignment: .center) { Text("iOS \(UIDevice.current.systemVersion)") .font(.largeTitle) Text("Tapped Location") Text("\(location.x), \(location.y)") } .frame(maxWidth: .infinity, alignment: .center) .background(.background) } } } Demo The gifs below show the behavior in iOS 18.5 (in which the tap gestures are recognized and tapped coordinate is displayed in the safe area inset) and iOS 26 beta 5 (in which the tap gestures have no effect): iOS 18 iOS 26 Next steps? Is there a recommended workaround for this issue?
18
4
484
5d
Any way to have the old Sidebar look with macOS 26 SDK?
Sadly my app doesn't look too good with the new sidebar style and currently I don't have the time to redesign it. (That will come later). When using Xcode 26 is there a way to keep the sidebar behavior but use the old Sequoia look? I initialize my sidebar splitview item with NSSplitViewItem(sidebarWithViewController: - when I switch to a different inititalizer (contentlist, inspector) it looks OK but the sidebar behavior (tracking toolbar item) is gone and the toolbar looks broken. Any other way to keep the old style besides not upgrading to Xcode 26? (The friendly integrated AI hallucinated some BS and then somehow applied those changes to my code ... luckily I had no pending code changes and could just revert via git).
Topic: UI Frameworks SubTopic: AppKit
0
0
39
5d
How to disable tab editing in a UITabBarController sidebar?
I’m creating a UITabBarController with a simple array of UITab instances. I’m setting the mode to .tabSideBar. How do I prevent editing? I don’t want the Edit button to appear at all. I’ve tried setting the tab controller’s customizableViewControllers property to both nil and an empty array but neither is preventing the Edit button from appearing. I scanned the various delegates and I don‘t see any relevant methods. So far I’ve tested this on a simulated iPad running iPadOS 26 using Xcode 26 RC.
2
0
89
5d
SwiftUI's `WebPage` back navigation not working as expected
I'm currently testing SwiftUI's WebKit by building a browsing application. For the back navigation, I have the following code implemented: if let item = webPage.backForwardList.backList.last { webPage.load(item) print( """ ===== backForwardList.backList: \(webPage.backForwardList.backList) --- backForwardList.currentItem: \(webPage.backForwardList.currentItem) --- backForwardList.forwardList: \(webPage.backForwardList.forwardList) ===== """.trimmingCharacters(in: .whitespacesAndNewlines) ) } When I look at the logs, it shows that whenever I navigate back, the currentItem is updated with the item, but the backList is appended with the previous currentItem, and the forwardList is always empty. Am I implementing this incorrectly? Thanks in advance!
0
0
58
5d
MultiDatePicker bug in iOS26
Hi! I've encountered strange bug in iOS 26. The MultiDatePicker component exhibits unreliable behavior when attempting to deselect previously chosen dates. Users often need to tap a selected date multiple times (e.g., tap to deselect, tap to re-select, then tap again to deselect) for the UI to correctly register the deselection and update the displayed state. This issue does not occur on iOS 18 or Xcode 26 previews, where MultiDatePicker functions as expected, allowing single-tap deselection. The bug only occurs on physical device or simulator. I can't lie, I have multidatepicker as crucial component in my larger app and can't really find a solution to this. Has anyone encountered this problem before? Here is the code to replicate the issue: import SwiftUI struct ContentView: View {     @ State private var selectedDates: Set = []     var body: some View {         NavigationStack {             Form {                 Section {                     MultiDatePicker("Select Dates", selection: $selectedDates)                 } header: {                     Text("MultiDatePicker Bug Test")                 }                 Section {                     Text("Selected Dates Count: (selectedDates.count)")                     ForEach(Array(selectedDates).sorted(by: {                         Calendar.current.date(from: $0)! < Calendar.current.date(from: $1)!                     }), id: .self) { dateComponent in                         if let date = Calendar.current.date(from: dateComponent) {                             Text(date.formatted(date: .long, time: .omitted))                         }                     }                 } header: {                     Text("Current State of Selected Dates")                 }             }             .navigationTitle("Date Picker Bug")         }     } } #Preview {     ContentView() }
0
0
32
5d
iOS 26 Beta breaks scroll/gesture in SwiftUI chat (worked in iOS 18): Simultaneous gestures & ScrollViewReader issues
Hi all, After upgrading to the iOS 26 beta, the scrolling in my SwiftUI chat view is completely broken. The exact same code works perfectly on iOS 18. Context: I have a chat view using ScrollViewReader and a vertically-reversed ScrollView (with .rotationEffect(.degrees(180))). Each message row (MessageBubble) uses multiple simultaneousGesture handlers: Horizontal drag for swipe-to-reply (and other actions: pin, delete) Long press for showing popover/actions Vertical scroll for normal chat scrolling This was working great on iOS 18. In iOS 26 beta, the vertical scroll is either completely disabled, jittery, or hijacked by the message row’s drag gestures, even though .simultaneousGesture is used (see code below). Minimal Repro Sample MessageListView.swift swift Copy Edit ScrollViewReader { proxy in ScrollView(.vertical, showsIndicators: false) { LazyVStack(spacing: 0) { // ... grouped messages ForEach(...) { ... MessageBubble(...) // see below } Color.clear.frame(height: 8).id("BOTTOM_ANCHOR") } .padding(.horizontal, 4) .rotationEffect(.degrees(180)) } .rotationEffect(.degrees(180)) } MessageBubble.swift struct MessageBubble: View { // ... var body: some View { // horizontal swipe-to-reply gesture let dragGesture = DragGesture(minimumDistance: 10) // ... ZStack { // ... HStack { ... } // ... .simultaneousGesture( DragGesture(minimumDistance: 0) // for long press // ... ) .simultaneousGesture(dragGesture) // for horizontal swipe } // ... } }
8
10
353
5d
UIGlassEffect is black
UIGlassEffect is giving a black rectangle, I tried setting the effect directly and in the animation block, but It does not make a difference. Replacing the effect with Blur sets the effect as expected. If there is another view inside the visualeffect.contentView it's not displayed as well. I tried setting the layout constraints as well as manually setting the frame of the VisualEffectView with no luck. iOS 26.0 (23A341)
Topic: UI Frameworks SubTopic: UIKit
0
0
31
5d
macOS Tahoe: NSView -cacheDisplayInRect:toBitmapImageRep: Doesn't Work on NSButton that uses NSBezelStyleGlass
If I try making a bitmap of a NSButton using the following code: NSBitmapImageRep *rep = [button bitmapImageRepForCachingDisplayInRect:button.bounds]; [button cacheDisplayInRect:button.bounds toBitmapImageRep:rep]; NSData *tiffData = rep.TIFFRepresentation; I get a blank image if the NSButton has its bezelStyle set to NSBezelStyleGlass. If I change the bezel style to something else like NSBezelStyleFlexiblePush I do get an image
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
23
5d
macOS Tahoe: NSView -cacheDisplayInRect:toBitmapImageRep: Doesn't Work Unless View is Added to Window
Previously I was able to "snapshot" view that were not part of any window hierarchy using the following: NSImage *buttonImage = [NSImage imageWithSystemSymbolName:@"49.circle.fill" accessibilityDescription:nil]; NSButton *aButton = [NSButton buttonWithImage:buttonImage target:nil action:nil]; [aButton sizeToFit]; NSBitmapImageRep *rep = [aButton bitmapImageRepForCachingDisplayInRect:aButton.bounds]; if (rep == nil) { NSLog(@"Failed to get bitmap image rep."); return; } [aButton cacheDisplayInRect:aButton.bounds toBitmapImageRep:rep]; NSData *tiffData = rep.TIFFRepresentation; NSImage *snapShotOfImage = [[NSImage alloc]initWithData:tiffData]; Now on macOS Tahoe I get a non nil image, but the image is blank. However if I add aButton NSWindow's view hiearchy just before the call to -cacheDisplayInRect:toBitmapImageRep: I do get a proper image. Is this behavior intended or is this considered a bug? Is it documented anywhere that a view must be in a NSWindow for -cacheDisplayInRect:toBitmapImageRep: to work? Thanks
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
28
5d
SwiftUI crash on OSX 26 using NSColorPanel
Crashlog-0916-071225.log I have an app that crashes on OSX 26 only. I have a @StateObject which is an observer of the NSColorPanel. When I call let panel = NSColorPanel.shared in init(), SwiftUI will crash - apparently with an update while view is being updated. See crash log. I was able to work around it by adding let _ = NSColorPanel.shared in my AppDelegate before SwiftUI is initialized. The exact code worked fine in all previous OSX versions.
0
0
28
6d
How to add blur around the Tab bar in iOS 26
I have a TabView and in one of the tabs I have a horizontal ScrollView that uses .scrollTargetBehavior(.paging) in each of those pages I have a List, but the bottom of the list around the Tab bar doesnt get blurred, if I remove the horizontal scrollview and just have a list it blurs fine. So I want to know how I can manually add the blur when using the horizontal scrollview
1
0
112
6d
Nested NavigationSplitView has unexpected layout shift inside a TabView
I have initialized a new SwiftUI project for iOS. I wrapped the default NavigationSplitView from SwiftData inside a TabView and ran into the following issue: On an iPad (Air, 13 inch, iPadOs 26), the button to open/close the sidebar shifts downwards while opening or closing the sidebar. When the animation finishes, the button jumps back to the original position. Here's the code I used inside my ContentView: var body: some View { TabView { Tab("Kategorien", systemImage: "circle.fill") { NavigationSplitView { List { ForEach(items) { item in NavigationLink { Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))") } label: { Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard)) } } .onDelete(perform: deleteItems) } .toolbar { ToolbarItem(placement: .navigationBarTrailing) { EditButton() } ToolbarItem { Button(action: addItem) { Label("Add Item", systemImage: "plus") } } } } detail: { Text("Select an item") } } Tab("Alle Bücher", systemImage: "circle.fill") { Text("Alle Bücher") } } }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
36
6d
Disable iOS 26 UINavigationBar Auto Intvert Background and Title
I have a UISplitView with a UINavigationBar where I on iPhone have an issue with a containing UITableView which is not directly placed under the NavigationBar. When the new effect in iOS 26 kicks in it also seems to affect to topmost UINavigationBar which I do not want. It's when the clear UINavigationBar directly over the UITableView and passes over a content that it needs to invert its title over, it does. However it also inverts everything (background + title) of another topmost uinavigationbar which I don't want. This is even opaque and have no reason to invert its colors. Any ideas on how to disable this? navigationItem.style = .editor navigationItem.centerItemGroups = [editorNavigationHelper.iPadCenterItemGroup()] navigationItem.rightBarButtonItems = editorNavigationHelper.rightBarButtonItems() let documentProperties = UIDocumentProperties(url: document.fileURL) if let itemProvider = NSItemProvider(contentsOf: document.fileURL) { documentProperties.dragItemsProvider = { _ in [UIDragItem(itemProvider: itemProvider)] } documentProperties.activityViewControllerProvider = { UIActivityViewController(activityItems: [itemProvider], applicationActivities: nil) } } navigationItem.title = if UIDevice.current.isIPhone { document.localizedName.trimmedToMax(12, appendingDots: true, adjustForDots: true) } else { document.localizedName } navigationItem.documentProperties = documentProperties navigationItem.titleMenuProvider = { [weak self] suggested in guard let self else { return UIMenu(children: []) } let custom = [ // ... ] return UIMenu(children: suggested + custom) } let navAppearance = UINavigationBarAppearance() navAppearance.configureWithOpaqueBackground() navAppearance.backgroundColor = UIColor.systemBackground navAppearance.titleTextAttributes = [.foregroundColor: UIColor.label] if let navBar = navigationController?.navigationBar { navBar.standardAppearance = navAppearance navBar.scrollEdgeAppearance = navAppearance navBar.compactAppearance = navAppearance navBar.isTranslucent = false navBar.backgroundColor = .systemBackground }
Topic: UI Frameworks SubTopic: UIKit
1
0
86
6d
Abnormal problem when sliding tableview cell
I created a tableview with two cells and configured a left-swipe action for each cell. When I swipe left, the cell displays normally. When I swipe the cell back to its original position, the view displays normally. When I quickly swipe right after the cell has been reset, the view displays noticeably abnormally.
Topic: UI Frameworks SubTopic: UIKit
1
0
31
6d
SwiftUI inspector inside NavigationStack causes scrolling and transition issues
We’ve encountered an issue while developing with SwiftUI: when using the inspector on iPadOS, if the inspector is placed inside a NavigationStack, and both the view attached to the inspector and the content inside the inspector itself are scrollable, scrolling them to the top may cause abnormal jitter. We suspect this issue might be related to NavigationTitle. However, if we place the inspector outside the NavigationStack, tapping any NavigationLink while the inspector is expanded will cause problems with the View.matchedTransitionSource(id:in:) animation. A reproducible project can be found here: https://github.com/ThreeManager785/Inspetor-Issue We’ve tried many approaches but haven’t been able to resolve it. Is there any way to fix this issue?
1
0
102
6d
iOS 26 navigationTransition .zoom issue
When I dismiss a view presented with .navigationTransition(.zoom), the source view gets a weird background (black or white depending on the appearance) for a couple of seconds, and then it disappears. Here’s a simple code example. import SwiftUI struct NavigationTransition: View { @Namespace private var namespace @State private var isSecondViewPresented = false var body: some View { NavigationStack { ZStack { DetailView(namespace: namespace) .onTapGesture { isSecondViewPresented = true } } .fullScreenCover(isPresented: $isSecondViewPresented) { SecondView() .navigationTransition(.zoom(sourceID: "world", in: namespace)) } } } } struct DetailView: View { var namespace: Namespace.ID var body: some View { ZStack { Color.blue Text("Hello World!") .foregroundStyle(.white) .matchedTransitionSource(id: "world", in: namespace) } .ignoresSafeArea() } } struct SecondView: View { var body: some View { ZStack { Color.green Image(systemName: "globe") .foregroundStyle(Color.red) } .ignoresSafeArea() } } #Preview { NavigationTransition() }
4
4
171
6d