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

Programmatic motion on the mouse cursor triggers "shake to locate"
I use the following code to keep the mouse cursor within the bounds of my application window. This causes the mouse cursor to become magnified while hugging the window's edges. Is there a way to prevent this? My clients are building a game, board style with a large map viewed from a top camera. They want the map to pan automatically when the mouse reaches the edge of the window. And they want the mouse cursor to stay confined to the game window. Thank you. CGDisplayMoveCursorToPoint(CGMainDisplayID(), location); // Removes a delay introduced by CGWarpMouseCursorPosition to keep mouse cursor motion fluid while hugging the screen edges CGEventSourceRef eventSourceRef = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState); CGEventSourceSetLocalEventsSuppressionInterval(eventSourceRef, 0);
0
0
38
4d
Implicit list row animations broken in Form container on iOS 26 beta 3
[Submitted as FB18870294, but posting here for visibility.] In iOS 26 beta 3 (23A5287g), implicit animations no longer work when conditionally showing or hiding rows in a Form. Rows with Text or other views inside a Section appear and disappear abruptly, even when wrapped in withAnimation or using .animation() modifiers. This is a regression from iOS 18.5, where the row item animates in and out correctly with the same code. Repro Steps Create a new iOS App › SwiftUI project. Replace its ContentView struct with the code below Build and run on an iOS 18 device. Tap the Show Middle Row toggle and note how the Middle Row animates. Build and run on an iOS 26 beta 3 device. Tap the Show Middle Row toggle. Expected Middle Row item should smoothly animate in and out as it does on iOS 18. Actual Middle Row item appears and disappears abruptly, without any animation. Code struct ContentView: View { @State private var showingMiddleRow = false var body: some View { Form { Section { Toggle( "Show **Middle Row**", isOn: $showingMiddleRow.animation() ) if showingMiddleRow { Text("Middle Row") } Text("Last Row") } } } }
1
3
128
4d
iOS 26 Floating Search Tab in UIKit
Does anyone have any documentation for how to achieve the floating search tab item in UIKit apps that use UITabBarController? The Liquid Glass UIKit video had code for minimizing the tab bar on scroll down, but I didn't see anything on keeping the search button locked to the bottom trailing edge (as in this screenshot below).
3
0
166
5d
How to use protocols to support managing SwiftUI views from different modules ?
In out project, we are creating a modular architecture where each module conform to certain protocol requirements for displaying the UI. For example: public protocol ModuleProviding: Sendable { associatedtype Content: View /// Creates and returns the main entry point view for this module /// - Parameter completion: Optional closure to be called when the flow completes /// - Returns: The main view for this module @MainActor func createView(_ completion: (() -> Void)?) -> Content } This protocol can be implemented by all different modules in the app, and I use a ViewProvider structure to build the UI from the module provided: public struct ViewProvider: Equatable { let id = UUID() let provider: any ModuleProviding let completion: () -> Void public init(provider: any ModuleProviding, completion: @escaping () -> Void) { self.provider = provider self.completion = completion } @MainActor public func layoutUI() -> some View { provider.createView(completion) } This code throws an error: Type 'any View' cannot conform to 'View' To solve this error, there are two ways, one is to wrap it in AnyView, which I don't want to do. The other option is to type check the provider with its concrete type: @ViewBuilder @MainActor private func buildViewForProvider(_ provider: any ModuleProviding, completion: (() -> Void)?) -> some View { switch provider { case let p as LoginProvider: p.createView(completion) case let p as PostAuthViewProvider: p.createView(completion) case let p as OnboardingProvider: p.createView(completion) case let p as RewardsProvider: p.createView(completion) case let p as SplashScreenProvider: p.createView(completion) default: EmptyView() } } This approach worked, but it defeats the purpose of using protocols and it is not scalable anymore. Are there any other approaches I can look at ? Or is this limitation in SwiftUI ?
3
0
89
5d
Disable Hit Testing on SwiftUI Map Annotation Content
Hi, I’m using SwiftUI’s Map with custom Annotation content and trying to make the annotation view ignore touch interactions—similar to applying .allowsHitTesting(false) on regular views. The goal is to ensure that map gestures such as long press and drag are not blocked by annotation content. However, setting .allowsHitTesting(false) on the annotation content doesn’t seem to have any effect. Is there any workaround or supported approach to allow the map to receive gestures even when they originate from annotation views? Thanks in advance for any guidance!
0
0
56
5d
Keeping the glass-style background inside a sheet with presentationDetents when navigating inside the sheet
Is there a way to keep the glass-style background on iOS 26 for a sheet with .presentationDetents when you navigate into a NavigationStack inside the sheet? Root level with glass: After following a NavigationLink inside the stack, the background is always opaque: The UI I'm building is somewhat similar to the Maps app, which resorts to showing another sheet on top of the main sheet when you select a location on the Map). I'm trying to get a similar look but with a proper navigation hierarchy inside the sheet's stack. Example code: import SwiftUI import MapKit struct ContentView: View { var body: some View { Map() .sheet(isPresented: .constant(true)) { NavigationStack { VStack { Text("Hello") NavigationLink("Show Foo") { Text("Foo") .navigationTitle("Foo") .presentationBackground(Color.clear) } } } .presentationDetents([.medium, .large]) .presentationBackgroundInteraction(.enabled) } } } #Preview { ContentView() }
Topic: UI Frameworks SubTopic: SwiftUI
1
0
160
5d
Using NSHostingSceneRepresentation to open arbitrary window in AppKit app
I’m trying to open a window from a SwiftUI Scene inside an AppKit app using NSHostingSceneRepresentation (macOS 26). The idea is that I want to call openWindow(id: "some-id") to show the new window. However, nothing happens when I try this — no window appears, and there’s nothing in the logs. Interestingly, if I use the openSettings() route instead, it does open a window. Does anyone know the correct way to open an arbitrary SwiftUI window scene from an AppKit app? import Cocoa import SwiftUI @main class AppDelegate: NSObject, NSApplicationDelegate { let settingsScene = NSHostingSceneRepresentation { #if true MyWindowScene() #else Settings { Text("My Settings") } #endif } func applicationWillFinishLaunching(_ notification: Notification) { NSApplication.shared.addSceneRepresentation(settingsScene) } @IBAction func showAppSettings(_ sender: NSMenuItem) { #if true settingsScene.environment.openWindow(id: MyWindowScene.windowID) #else settingsScene.environment.openSettings() #endif } } struct MyWindowScene: Scene { static let windowID = "com.company.MySampleApp.myWindow" var body: some Scene { Window("Sample Window", id: MyWindowScene.windowID) { Text("Sample Content") .scenePadding() } } }
Topic: UI Frameworks SubTopic: SwiftUI
0
0
65
5d
iOS 26 ScrollView with static background image
I need a layout where I have a ScrollView with some content, and ScrollView has full screen background image. Screen is pushed as detail on stack. When my screen is pushed we display navigation bar. We want a new scrollEdgeEffectStyle .soft style work. But when we scroll the gradient blur effect bellow bars is fixed to top and bottom part of the scroll view background image and is not transparent. However when content underneath navigation bar is darker and navigation bar changes automatically to adapt content underneath the final effect looks as expected doesn't use background image. Expected bahaviour for us is that the effect under the navigation bar would not use background image but would be transparent based on content underneath. This is how it is intialy when user didn't interact with the screen: This is how it looks when user scrolls down: This is how it looks when navigation bar adapts to dark content underneath: Minimal code to reproduce this behaviour: import SwiftUI @main struct SwiftUIByExampleApp: App { var body: some Scene { WindowGroup { ContentView() } } } struct ContentView: View { var body: some View { NavigationStack { ScrollView(.vertical) { VStack(spacing: 0.0) { ForEach(1 ..< 101, id: \.self) { i in HStack { Text("Row \(i)") Spacer() } .frame(height: 50) .background(Color.random) } } } .scrollEdgeEffectStyle(.soft, for: .all) .scrollContentBackground(.hidden) .toolbar { ToolbarItem(placement: .title) { Label("My Awesome App", systemImage: "sparkles") .labelStyle(.titleAndIcon) } } .toolbarRole(.navigationStack) .background( ZStack { Color.white .ignoresSafeArea() Image(.sea) .resizable() .ignoresSafeArea() .scaledToFill() } ) } } } extension Color { static var random: Color { Color( red: .random(in: 0...1), green: .random(in: 0...1), blue: .random(in: 0...1) ) } } We've also tried using ZStack instead of .background modifier but we observed the same results. We want to basically achieve the same effect as showcased here, but with the static background image: https://youtu.be/3MugGCtm26A?si=ALG29NqX1jAMacM5&t=634
0
0
105
5d
UIRequiresFullScreen in iPadOS 26
Our app includes the UIRequiresFullScreen plist key, but the iPadOS 26 betas seem to ignore this. The window handle is still displayed, and while the window aspect ratio seems to be constrained, you can still adjust it and arrange it alongside other apps. We do not want to support windowing or multi-tasking, and the WWDC sessions indicated there would be a way to opt out of the new windowing system. Has UIRequiresFullScreen been silently deprecated, or are we missing something in our implementation?
5
0
182
5d
App is crashing on iPad after upgrading to iOS 26 when we push from one screen to another with data using segue but working fine on iPhone
Error: Fatal error: init(coder:) has not been implemented File: UIKitCore/UICoreHostingView.swift:54 Stack Trace Snippet: swift Copy Edit UIKitCore/UICoreHostingView.swift:54: Fatal error: init(coder:) has not been implemented Can't show file for stack frame: &lt;DBGLldbStackFrame: 0x10ca74560&gt; - stackNumber: 23 name: @objc ThemeableViewController.init(coder:). The file path does not exist on the file system: /
1
0
147
5d
`ContextMenu` and `Menu` Item Layout: Icon/Title Order Discrepancy Between System and Custom Apps (iOS 26)
I've observed a difference in the layout of menu items within ContextMenu and Menu when comparing system applications to my own SwiftUI app, specifically concerning the order of icons and titles. On iOS 26, system apps (as shown in the image in the "System App" column) appear to display the item's icon before its title for certain menu items. However, in my SwiftUI app, when I use a Label (e.g. Label("Paste", systemImage: "doc.on.clipboard")) or an HStack containing an Image and Text, the icon consistently appears after the title within both ContextMenu and Menu items. I'm aiming to achieve the "icon first, then title" layout as seen in system apps. My attempts to arrange this order using HStack directly within the Button's label closure: Menu { Button { /* ... */ } label: { HStack { Image(systemName: "doc.on.clipboard") Text(String(localized: "Paste")) } } // ... } label: { Text("タップミー") } seem to be overridden or restricted by the OS, which forces the icon to the leading position (as shown in the image in the "Custom App" column). System App Custom App Is there a specific SwiftUI modifier, or any other setting I might have overlooked that allows developers to control the icon/title order within ContextMenu or Menu items to match the system's behavior? Or is this a system-controlled layout that app developers currently cannot customize, and we need to wait for potential changes from Apple to expose this capability for in-app menus? Thanks in advance!
1
0
130
5d
UISheetPresentationController with top attached views
I am using UISheetPresentationController to show bottom sheets like the one in Apple Maps. It works very well. In Apple Maps, there is a weather indicator that sits on top of the presented sheets and follows it (to a point) when the sheet is dragged up or down. I would like to mimic this behavior for my own bottom sheets to have content from the presenting view controller stay visible while the sheet is presented. How do I do this? Is this even possible? I think I'm looking for some kind of layout guide that sits on top of the presented sheet.
Topic: UI Frameworks SubTopic: UIKit
1
1
45
5d
iOS 26 Beta 3 `safeAreaInsets`
I noticed that trying to access safeAreaInsets from the active window causes an infinite run loop. This issue appeared after updating to Beta 3. Here’s an example of the code: extension UIDevice { var safeAreaInsets: UIEdgeInsets { guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let window = windowScene.windows.first(where: { $0.isKeyWindow }) else { return .zero } return window.safeAreaInsets } } The return doesn’t happen because it ends up in some kind of recursion.
2
0
180
5d
Buttons in the bottom bar of an inspector appear disabled
Buttons placed in the bottomBar and keyboard toolbar item positions in an inspector appear disabled/grayed out when at the large presentation detent. The same is not true for sheets. Is this intentional or a bug? If intentional, is there any backing design theory in the Human Interface Guidelines for it? Xcode 16.4 / 18.5 simulator // Inspector @ large detent struct ContentView: View { var body: some View { Color.clear .inspector(isPresented: .constant(true)) { Color.clear .presentationDetents([.large]) .toolbar { ToolbarItem(placement: .bottomBar) { Button("Save") {} .border(.red) } } } } } // Sheet struct ContentView: View { var body: some View { Color.clear .sheet(isPresented: .constant(true)) { Color.clear .presentationDetents([.medium]) .toolbar { ToolbarItem(placement: .bottomBar) { Button("Save") {} .border(.red) } } } } }
0
0
101
5d
Interrupting a custom view controller presentation transition results in sudden disappearance
I’ve implemented a basic custom view controller presentation: the presented view controller slides up from the bottom in a manner similar to UISheetPresentationController, and can be dismissed by tapping the dimming view added on top of the presenting view controller. I want my custom presentation to be interruptible, so the user should be able to tap the dimming view while the presentation transition is in progress to smoothly convert the presentation transition into a dismissal transition. I’m using additive spring animations (by virtue of UIViewPropertyAnimator) here to make the change in direction less jarring. Unfortunately, it seems that the interruption-triggered dismissal transition is abruptly terminated by the system based on some kind of timer. The later in the presentation transition I tap the dimming view, the earlier the dismissal transition is terminated. Steps to reproduce After launching the test project: Tap the “Present” button. Tap the dimming view just before the transition completes. The test project includes a screen recording of the broken behavior.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
92
5d
How can I make an "inverted" list (bottom to top) with SwiftUI?
I'm trying to figure out how to make an inverted list in my watchOS app for a message view, so that messages appear from the bottom first, and go up. Everything I've tried so far has some sort of major drawback, and I'm wondering if there's some proper way to do it. My current implementation is flipping every message item upside-down, then flipping the whole list upside-down. This works in making the list go from bottom to top, but the digital crown scroll direction is also inverted. Simply inverting the array of messages doesn't work either, as the user has to scroll to the bottom of the list manually every time. Any tips/suggestions would be greatly appreciated.
1
0
431
6d