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

Can SwiftUI Views serve as delegates?
Structs are value types, and the SwiftUI gets reinitialized many times throughout its lifecycle. Whenever it gets reinitialized, would the reference that the delegator has of it still work if the View uses @State or @StateObject that hold a persistent reference to the views data? protocol MyDelegate: AnyObject { func didDoSomething() } class Delegator { weak var delegate: MyDelegate? func trigger() { delegate?.didDoSomething() } } struct ContentView: View, MyDelegate { private let delegator = Delegator() @State counter = 1 var body: some View { VStack { Text("\(counter)") Button("Trigger") { delegator.trigger() } } } func didDoSomething() { counter += 1 //would this call update the counter in the view even if the view's instance is copied over to the delegator? } }
0
0
39
1w
UITabBar ignores font in iOS 26.2
Our app has a UITabBar and the compactInlineLayoutAppearance has a custom font set. This worked fine on iOS 26.0 and 26.1. [self.bottomTabBar.standardAppearance.compactInlineLayoutAppearance.normal setTitleTextAttributes: @{ NSFontAttributeName:[UIFont fontWithName:@"AvenirNext-DemiBold" size:18.0] }]; But on iOS 26.2, the system ignores this custom font. How can I apply a custom font to a UITabBar on iOS 26.2?
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
141
1w
CoreAutoLayout -[NSISEngine _flushPendingRemovals] crash
crash stack: Crashed: com.apple.main-thread 0 libsystem_pthread.dylib 0x90c thread_chkstk_darwin + 60 1 libsystem_pthread.dylib 0x90c ___chkstk_darwin + 60 2 CoreAutoLayout 0x14c4 -[NSISEngine _flushPendingRemovals] + 56 3 CoreAutoLayout 0x2de08 -[NSISEngine _coreReplaceMarker:withMarkerPlusDelta:].cold.1 + 64 4 CoreAutoLayout 0x15d78 -[NSISEngine _coreReplaceMarker:withMarkerPlusDelta:] + 204 5 CoreAutoLayout 0x2ce38 -[NSISEngine constraintDidChangeSuchThatMarker:shouldBeReplacedByMarkerPlusDelta:] + 108 6 CoreAutoLayout 0x15f1c -[NSISEngine tryToChangeConstraintSuchThatMarker:isReplacedByMarkerPlusDelta:undoHandler:] + 100 7 CoreAutoLayout 0x2fdbc -[NSLayoutConstraint _tryToChangeContainerGeometryWithUndoHandler:] + 252 8 CoreAutoLayout 0x3020c -[NSLayoutConstraint _setSymbolicConstant:constant:symbolicConstantMultiplier:] + 452 9 CoreAutoLayout 0x30378 -[NSLayoutConstraint setConstant:] + 84 10 UIKitCore 0x51c3c __74-[UIView(UIConstraintBasedLayout) _autoresizingConstraints_frameDidChange]_block_invoke + 140 11 UIKitCore 0x1841174 -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 112 12 UIKitCore 0x51b28 -[UIView(UIConstraintBasedLayout) _autoresizingConstraints_frameDidChange] + 452 13 UIKitCore 0x2c894 -[UIView _constraints_frameDidChange] + 100 14 UIKitCore 0x18fac08 -[UIView(Geometry) setFrame:] + 576 15 UIKitCore 0x96712c -[UITabBar setFrame:] + 128 16 UIKitCore 0x1666f4 -[_UITabBarControllerVisualStyle updateTabBarLayout] + 360 17 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 18 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 19 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 20 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 21 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 22 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 23 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 24 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 25 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 26 UIKitCore 0x16671c -[_UITabBarControllerVisualStyle updateTabBarLayout] + 400 27 UIKitCore 0x16642c -[UITabBarController _prepareTabBar] + 128 28 UIKitCore 0x166a10 -[UITabBarController _layoutContainerView] + 376 29 UIKitCore 0x1677a8 -[UITabBarController __viewWillLayoutSubviews] + 28 30 UIKitCore 0x147078 -[UILayoutContainerView layoutSubviews] + 176 31 UIKit 0xb14a0 -[UILayoutContainerViewAccessibility layoutSubviews] + 60 for a more detail crash stack, can see attach file: crash.txt crash probabilistic happed after app enter background, and our app support landscape, when crash appear, the system method: /* This method is called when the view controller's view's size is changed by its parent (i.e. for the root view controller when its window rotates or is resized). If you override this method, you should either call super to propagate the change to children or manually forward the change to children. */ - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator API_AVAILABLE(ios(8.0)); is called; but for a normal not crash case, when enter background and rotate device, the viewWillTransitionToSize method is not called until app enter foreground; Are there any suggestions that can help solve this problem, thank you.
1
0
167
1w
Should TabView with .page style support keyboard left/right navigation automatically?
I’m trying to understand the expected behavior of TabView when using .tabViewStyle(.page) on iPadOS with a hardware keyboard. When I place a TabView in page mode, swipe gestures correctly move between pages. However, left and right arrow keys do nothing by default, even when the view is made focusable. This feels a bit surprising, since paging with arrow keys seems like a natural keyboard interaction when a keyboard is attached. Right now, to get arrow-key navigation working, I have to manually: Make the view focusable Listen for arrow key presses Update the selection state manually This works, but it feels a little tedious for something that seems like it could be built-in. import SwiftUI struct PageTabsExample: View { @State private var selection = 0 private let pageCount = 3 var body: some View { TabView(selection: $selection) { Color.red.tag(0) Color.blue.tag(1) Color.green.tag(2) } .tabViewStyle(.page) .indexViewStyle(.page) .focusable(true) .onKeyPress(.leftArrow) { guard selection > 0 else { return .ignored } selection -= 1 return .handled } .onKeyPress(.rightArrow) { guard selection < pageCount - 1 else { return .ignored } selection += 1 return .handled } } } My questions: Is this lack of default keyboard paging for page-style TabView intentional on iPadOS with a hardware keyboard? Is there a built-in way to enable arrow-key navigation for page-style TabView, or is manual handling the expected approach? Does my approach above look like the “SwiftUI-correct” way to do this, or is there a better pattern for integrating keyboard navigation with paging? For this kind of behavior, is it generally recommended to use .onKeyPress like I’m doing here, or would .keyboardShortcut be more appropriate (for example, wiring arrow keys to actions instead)? Any guidance or clarification would be greatly appreciated. I just want to make sure I’m not missing a simpler or more idiomatic solution. Thanks!
0
0
94
1w
Buttons on tvOS with text are blurred
When adding buttons to a sheet, on tvOS the text is blurred in the buttons, making it illegible. Feedback: FB21228496 (used GPT to extract an example from my project for a test project to attach here) // ButtonBlurTestView.swift // Icarus // // Test view to reproduce blurred button issue on tvOS // import SwiftUI struct ButtonBlurTestView: View { @State private var showSheet = false @State private var selectedTags: [Int] = [] @State private var newTagName: String = "" // Hardcoded test data private let testTags = [ TestTag(id: 1, label: "Action"), TestTag(id: 2, label: "Comedy"), TestTag(id: 3, label: "Drama"), TestTag(id: 4, label: "Sci-Fi"), TestTag(id: 5, label: "Thriller") ] var body: some View { NavigationStack { VStack { Text("Button Blur Test") .font(.title) .padding() Button("Show Test Sheet") { showSheet = true } .buttonStyle(.borderedProminent) .padding() Text("Tap the button above to open a sheet with buttons inside a Form.") .font(.caption) .foregroundColor(.secondary) .multilineTextAlignment(.center) .padding() } .navigationTitle("Blur Test") .sheet(isPresented: $showSheet) { TestSheetView( selectedTags: $selectedTags, newTagName: $newTagName, testTags: testTags ) } } } } struct TestSheetView: View { @Environment(\.dismiss) private var dismiss @Binding var selectedTags: [Int] @Binding var newTagName: String let testTags: [TestTag] var body: some View { NavigationStack { VStack { // Header VStack { Text("Testing") .font(.title2) .bold() Text("Test TV Show") .font(.subheadline) .foregroundColor(.secondary) } .padding() // Form with buttons Form { Section(header: Text("Summary")) { Text("This is a test") .font(.subheadline) .foregroundColor(.secondary) } Section(header: Text("Tags")) { tagsSelectionView } } } .navigationTitle("Add") #if !os(tvOS) .navigationBarTitleDisplayMode(.inline) #endif .toolbar { ToolbarItem(placement: .cancellationAction) { Button("Cancel") { dismiss() } } ToolbarItem(placement: .confirmationAction) { Button("Add") { dismiss() } } } } } private var tagsSelectionView: some View { VStack(alignment: .leading) { // Tag pills in a grid let columns = [GridItem(.adaptive(minimum: 80), spacing: 8)] LazyVGrid(columns: columns, alignment: .leading, spacing: 8) { ForEach(testTags, id: \.id) { tag in TagPill( tag: tag, selected: selectedTags.contains(tag.id) ) { if selectedTags.contains(tag.id) { selectedTags.removeAll { $0 == tag.id } } else { selectedTags.append(tag.id) } } } } Divider() // Add new tag button HStack { TextField("New tag name", text: $newTagName) #if os(tvOS) .textFieldStyle(PlainTextFieldStyle()) #else .textFieldStyle(RoundedBorderTextFieldStyle()) #endif Button("Add") { // Test action newTagName = "" } .disabled(newTagName.trimmingCharacters(in: .whitespaces).isEmpty) } } } } // Tag Pill - matches the structure from original project private struct TagPill: View { let tag: TestTag let selected: Bool let action: () -> Void var body: some View { Button(action: action) { Text(tag.label) .font(.callout) .lineLimit(1) .padding(.horizontal, 12) .padding(.vertical, 8) .background( Capsule() .fill(selected ? Color.accentColor : Color.secondary.opacity(0.15)) ) .overlay( Capsule() .stroke(selected ? Color.accentColor : Color.secondary.opacity(0.35), lineWidth: 1) ) .foregroundStyle(selected ? Color.white : Color.primary) .contentShape(Capsule()) } .buttonStyle(.plain) #if os(tvOS) .focusable(true) #endif } } struct TestTag { let id: Int let label: String } #Preview { ButtonBlurTestView() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
1
0
131
1w
Detecting marked range in UI/NSTextViews at the time of shouldChangeTextIn
We have submitted a feedback for this issue: FB21230723 We're building a note-taking app for iOS and macOS that uses both UITextView and NSTextView. When performing text input that involves a marked range (such as Japanese input) in a UITextView or NSTextView with a UITextViewDelegate or NSTextViewDelegate set, the text view's marked range (markedTextRange / markedRange()) has not yet been updated at the moment when shouldChangeTextIn is invoked. UITextViewDelegate.textView(_:shouldChangeTextIn:replacementText:) NSTextViewDelegate.textView(_:shouldChangeTextIn:replacementString:) The current behavior is this when entering text in Japanese: (same for NSTextView) func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { print(textView.markedTextRange != nil) // prints out false DispatchQueue.main.async { print(textView.markedTextRange != nil) // prints out true } } However, we need the value of markedTextRange right away in order to determine whether to return true or false from this method. Is there any workaround for this issue?
0
0
81
1w
Paste button on navigation bar is not shown on iOS/iPadOS 26
The Paste button (using UIPasteControll) located on UINavigationBar is not shown at application startup on iOS/iPadOS 26. This issue will disappear when device is rotated or window size is changed. And this issue does not occur on iOS / iPadOS 18 and earlier. I uploaded the sample project to github at the following URL. https://github.com/gpn-galapagos/PasteButtonApp.git Has anyone had the same issue or knows a workaround?
0
0
155
1w
tvOS Focus Halo Does Not Respect cornerRadius on UIImageView
The Problem When using adjustsImageWhenAncestorFocused = true on a UIImageView in tvOS, the native focus halo effect does not respect the cornerRadius property set on the image view's layer. The image itself correctly clips to the rounded corners, but the focus halo (the glowing outline that appears when the view is focused) always renders with square or nearly-square corners. Code Example let imageView = UIImageView() imageView.layer.cornerRadius = 60 imageView.clipsToBounds = true imageView.adjustsImageWhenAncestorFocused = true imageView.image = posterImage Result: The poster image displays with 60pt rounded corners as expected, but when focused, the halo effect has square corners - creating an obvious visual mismatch. Expected Behavior The focus halo should follow the same cornerRadius as the UIImageView. If I set a 60pt corner radius, both the image and its focus halo should have matching 60pt rounded corners. Actual Behavior The image respects cornerRadius and displays with rounded corners The focus halo ignores cornerRadius and renders with square corners This creates an inconsistent, unpolished appearance Environment tvOS 16.0+ (tested through tvOS 18) Affects both Apple TV Simulator and physical devices Occurs with any corner radius value above approximately 20-30pt Use Case This is a common scenario for media streaming apps. Movie and TV show poster cards typically use rounded corners (40-80pt) as part of modern UI design. Many apps like Netflix, Plex, and others use this design pattern. The current behavior forces developers to choose between: Using the beautiful native focus effect but with mismatched square halos Implementing a completely custom focus effect from scratch, losing the native parallax, shadow, and halo animations Neither option is ideal. What I've Tried Setting cornerRadius before and after adjustsImageWhenAncestorFocused Different clipsToBounds configurations Wrapping the image view in a container view with corner radius Using layer.maskedCorners to specify which corners to round Subclassing CALayer to intercept sublayers added by the focus system None of these approaches affect the focus halo's corner radius. Request I would appreciate guidance on any of the following: Is there a supported way to customize the focus halo's corner radius? The UIFocusHaloEffect class exists on iOS/iPadOS but is not available on tvOS. Is this a bug that will be addressed? The focus system clearly reads some properties from the image view (like bounds), so it seems like cornerRadius should also be respected. Is there a different API I should be using? Perhaps there's an alternative approach to achieve rounded corner poster cards with matching focus effects that I'm not aware of. Additional Context I've noticed that some third-party apps have achieved this effect, suggesting it may be possible through undocumented means. However, I would prefer to use a public, supported API to ensure compatibility with future tvOS updates. Any guidance from Apple engineers or developers who have solved this would be greatly appreciated. Thank you.
Topic: UI Frameworks SubTopic: UIKit
0
0
92
1w
Interactive ColumnTable header?
AI's would have me believe that the header of a TableColumn in Table() can be modified to be interactive simply by adding a header: closure with a Button however no provided code actually compiles or reflects any documentation I can find. Is it possible to put something besides a Text object in the header?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
32
1w
CMD+ESC no longer working on macOS 26.1
Hi there! We have an application that exists for more than 10 years (Appkit, Obj-C), and since the very beginning we're using CMD+ESC as a keyboard shortcut for a very important function in our app. Until now, this worked great. Recently, when macOS 26.1 released our app started to not responding to CMD+ESC anymore for some of our customers - it seems like CMD+ESC never gets to our app at all. First, we though it's happening because Game Overlay is also using CMD+ESC by default, but when we turned that off, or switched that to something else in macOS's Keyboard preferences, the issue still persisted. The, we realized this has something to do with iCloud - so, if you turn off iCloud, do a log out and log in to your computer, and it's magically starts working again, as it always did. More strangely, this issue doesn't happen for everyone - for many of our customers, the issue seems to doesn't exist for some strange reason. Anyone have any idea what could be happening here?
Topic: UI Frameworks SubTopic: AppKit
0
0
45
1w
My app doesn't respond on iPhone Air iOS 26.1.
My app doesn't respond on iPhone Air iOS 26.1. After startup, my app shows the main view with a tab bar controller containing 4 navigation controllers. However, when a second-level view controller is pushed onto any navigation controller, the UI freezes and becomes unresponsive. The iPhone simulator running iOS 26.1 exhibits the same problem. The debug profile shows CPU usage at 100%. However, other devices and simulators do not have this problem.
5
3
230
1w
Cocoa - creating a text canvas for backing a terminal emulator
Dear Forum, after decades, I'm back to MacOS dev just for the need of it. Besides Mac, I'm also toying around with vintage IBM mainframe systems and therefore I'm in need for a good terminal emulation. So far, I use x3270 on my Apple Silicon M1 MacBook Air - nice. However, I can't compile it on my collection of vintage Macs (iMac G3, Cube G4) so I pondered to create it on my own using Cocoa (starting with MacOS X 10.4 Tiger up to the current level (on Sequoia) so that rules out Carbon. tn3270 X from Brown University works nice on those vintage Macs but misses some features. Having browsed some info about the Cocoa Text system, I wonder if that would be the right place to start. At the end of the day, I need to be able to intercept all keystrokes, have more or less a fixed font 80x25 (136x25 etc..) col/row layout of protected and unprotected areas where text can be entered. Cusor should be visible and movable by using cursor control keys. I'd be happy for any suggestion on where to start here. Kind regards Michael
Topic: UI Frameworks SubTopic: AppKit
0
0
49
1w
UISplitViewController.showDetailViewController() not working in iPhone version.
Since updating to Tahoe and Xcode 26 I have found that the UISplitViewController.showDetailViewController() is not working in the iPhone version of my app (it is a universal app). I'm just trying to show a detail view after a tap on a UITableView item. The iPad versions are all working correctly. Has anyone else experienced this or have any advice about what may have changed? Thanks in advance.
1
0
150
1w
UISplitViewController and setViewController:forColumn: differences between different iOS versions
It seems to be that the functionality of the method setViewController:forColumn: in the column-style layout of a UISplitViewController has changed. iOS 18: setViewController:forColumn: pushes a new view controller onto the UINavigationController if it existed before the call. iOS 26: setViewController:forColumn: sets or replaces the view controller with a new view controller as a root of a new UINavigationController. My questions: what is the intended behavior? I did not find any documentation about a change. how do I replace in iOS 18 the old view controller with the new view controller passed to setViewController:forColumn:?
0
0
144
2w
In SwiftUI, how to animate from an arbitrary corner radius to the corner radius of the display?
I am trying to implement a common UX/UI pattern: one view with rounded corners transitioning to a view that fills the screen (N.B. having the display's corner radius). I got this to work if both corner radiuses are equal to that of the display (see first GIF). However, I cannot seem to get it to work for arbitrary corner radiuses of the smaller view (i.e., the one that does not fill the screen). I expected the be able to combine ContainerRelativeShape with .containerShape (see code), but this left me with a broken transition animation (see second GIF). import SwiftUI struct ContentView: View { @Namespace private var animation @State private var selectedIndex: Int? var body: some View { ZStack { if let selectedIndex = selectedIndex { ContainerRelativeShape() .fill(Color(uiColor: .systemGray3)) .matchedGeometryEffect(id: "square-\(selectedIndex)", in: animation) .ignoresSafeArea() .onTapGesture { withAnimation() { self.selectedIndex = nil } } .zIndex(1) } ScrollView { VStack(spacing: 16) { ForEach(0..<20, id: \.self) { index in if selectedIndex != index { ContainerRelativeShape() // But what if I want some other corner radius to start with? .fill(Color(uiColor: .systemGray5)) .matchedGeometryEffect(id: "square-\(index)", in: animation) .aspectRatio(1, contentMode: .fit) .padding(.horizontal, 12) .onTapGesture { withAnimation() { selectedIndex = index } } // .containerShape(RoundedRectangle(cornerRadius: 20)) // I can add this to change the corner radius, but this breaks the transition of the corners } else { Color.clear .aspectRatio(1, contentMode: .fit) .padding(.horizontal, 12) } } } .padding(.vertical, 16) } } } } #Preview { ContentView() } What am I missing here? How can I get this to work? And where is the mistake in my reasoning?
1
0
99
2w