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

Preventing animation glitch when dismissing a Menu with glassEffect
Hi everyone, I’m running into a strange animation glitch when using a Menu inside a glassEffect container. Here’s a minimal example: import SwiftUI struct ContentView: View { @Namespace private var namespace var body: some View { ZStack { Image(.background) .resizable() .frame(maxWidth: .infinity, maxHeight: .infinity) .ignoresSafeArea() GlassEffectContainer { HStack { Button("b1") {} Button("b2") {} Button("b3") {} Button("b4") {} Button("b5") {} Menu { Button("t1") { } Button("t2") { } Button("t3") { } Button("t4") { } Button("t5") { } } label: { Text("Menu") } } } .padding(.horizontal) .frame(height: 50) .glassEffect() } } } What happens: The bar looks fine initially: When you open the Menu, the entire bar morphs into the menu: When dismissing, the bar briefly animates into a solid rectangle before reapplying the glass effect: Questions: Is there a way to prevent that brief rectangle animation when dismissing the menu? If not, is it possible to avoid the morphing altogether and have the menu simply overlay on top of the bar instead of replacing it? Any ideas or workarounds would be greatly appreciated!
0
0
258
2d
Popovers are broken on Catalyst builds without portrait support
On macOS 15.2, any Mac Catalyst project that does not support portrait iPad orientation will no longer be able to successfully show the contents of any popover controls. This does not appear to be a problem on earlier versions of macOS and it only affects Mac Catalyst builds, not "Designed for iPad" builds. STEPS TO REPRODUCE Create a project that utilizes Mac Catalyst. Create a simple button that shows a popover with simple content. Remove Portrait as a supported orientation. Run the project on macOS 15.2 as a Mac Catalyst build. Note that the content inside the popover is not shown the popover is shown. Run the project as Designed for iPad. Note that the popover content shows correctly.
3
2
309
2d
SwiftData and CloudKit: NSKeyedUnarchiveFromData Error
I just made a small test app that uses SwiftData with CloudKit capability. I created a simple Book model as seen below. It looks like enums and structs when used with CloudKit capability all trigger this error: 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release I fixed the error by using genreRaw String and using a computed property to use it in the app, but it popped back up after adding the ReadingProgress struct Should I ignore the error and assume Apple still supports enums and codable structs when using SwiftData with CloudKit? import SwiftData @Model class Book { var title: String = "" var author: String = "" var genreRaw: String = Genre.fantasy.rawValue var review: String = "" var rating: Int = 3 var progress: ReadingProgress? var genre: Genre { get { Genre(rawValue: genreRaw) ?? Genre.fantasy } set { genreRaw = newValue.rawValue } } init(title: String, author: String, genre: Genre, review: String, rating: Int, progress: ReadingProgress? = nil) { self.title = title self.author = author self.genre = genre self.review = review self.rating = rating self.progress = progress } } struct ReadingProgress: Codable { var currentPage: Int var totalPages: Int var isFinished: Bool var percentComplete: Double { guard totalPages > 0 else { return 0 } return Double(currentPage) / Double(totalPages) * 100 } } enum Genre: String, Codable, CaseIterable { case fantasy case scienceFiction case mystery case romance var displayName: String { switch self { case .fantasy: return "Fantasy" case .scienceFiction: return "Science Fiction" case .mystery: return "Mystery" case .romance: return "Romance" } } }
0
1
233
3d
Screen layout positioning in Swift
Hello everyone, I’m just trying to position these times and check boxes side by side as shown in the attachment. So far no matter what I try, it only lists. There are more fixed times for example 10:00am all the way to 6:30pm. The user picks the times that they are NOT available. This is a sample of the code below. The check boxes work fine, it’s just the screen layout I’m having issues with. Any advice will be appreciated. ..................................... import SwiftUI struct ContentView: View { @State private var wakeup = Date.now @State private var isCheckedOption900 = false @State private var isCheckedOption930 = false var body: some View { Text("Select unavailable Dates/Times") DatePicker("Please enter a date", selection: $wakeup) .labelsHidden() } Form{ Section("Enter Blockout times") { Toggle(isOn: $isCheckedOption900) { Text("9:00am") } .toggleStyle(CheckboxToggleStyle()) Toggle(isOn: $isCheckedOption930) { Text("9:30am") } .toggleStyle(CheckboxToggleStyle()) }
Topic: UI Frameworks SubTopic: SwiftUI
1
0
393
3d
UIToolbar size in iOS26
In my UIKit app, in my view controller, I have a toolbar at the bottom of the screen and a UITextView, and I need to get the size of the toolbar to calculate the correct keyboard intersection, and change my text view layout so that the text doesn't get obscured when the keyboard is shown on screen. It's been working fine till now, but with iOS26, I am running into an issue, because the toolbar size is completely different. For this code: NSInteger offset = (self.navigationController.isToolbarHidden == NO)? (self.navigationController.toolbar.frame.size.height): 0; iOS18 returns '49' iOS26 returns ''812'. This obviously throws off the calculations for keyboard avoidance. Is there a way to overcome this, other than ignoring or hard-coding toolbar height?
Topic: UI Frameworks SubTopic: UIKit
1
0
194
3d
SwiftUI #Previews: How to populate with data
Suppose you have a view: struct Library: View { @State var books = [] var body: some View { VStack { ... Button("add Book") { .... } } } Such that Library view holds a Book array that gets populated internally via a button that opens a modal – or something alike. How can I use #Peviews to preview Library with a pre-populated collection? Suppose I have a static books – dummy – array in my code just for that; still, what's the best way to use that to preview the Library view?
4
0
65
3d
The new navigationLinkIndicatorVisibility modifier crashes on < iOS 26
This new modifier is supposedly backported to iOS 17, but on attempting to use it on the latest iOS 18.5, this happens: Symbol not found: _$s7SwiftUI17EnvironmentValuesV33_navigationIndicatorVisibilityABIAA0G0OvpMV This happens with any usage of the modifier. An availability check won't save you either. The cruelest part of this is that I only need the modifier on iOS 26, lmao. Am I just missing something?
Topic: UI Frameworks SubTopic: SwiftUI
7
0
174
3d
UIBarButtonItems do not respect tintColor property set on a UINavigationItem
In iOS and iPadOS 26 beta 9 (and previous batas), setting the tintColor property on a navigation bar does not tint bar button items. The text and images are always black in the following cases: Buttons displaying only text (initWithTitle:) Buttons displaying only a symbol (initWithImage:) Buttons displaying system items, ie., UIBarButtonSystemItemCancel. Nav bar title The tintColor seems to be respected for: Selected-state background for buttons configured with changesSelectionAsPrimaryAction. To reproduce, Create a UINavigationController, Add bar button items to its navigation item, Set a tint color as in the following statement: self.navigationController.navigationBar.tintColor = [UIColor redColor]; Then note that the bar button items are black rather than red as expected. I have filed a feedback: FB19980265.
Topic: UI Frameworks SubTopic: UIKit
1
1
154
3d
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() }
2
4
112
3d
[Bug] iOS 26 double largeTitleView hides the largeTitle
Hello, I'm facing issues when using prefersLargeTitles on iOS26, as you can see in the UI hierarchy, the largeTitle is assigned to a UINavigationBarLargeTitleView but not in the UINavigationBar. On the other hand, iOS18 we only have the navigationBar largeTitle. Is this an identified issue, how can I fix it? We set the title and set prefersLargeTitles to true, do you know any reason this happens? Additionally, if I set the navigationBar.isTranslucent to false the extra NavigationBarLargeView in the TableView is non-existent. Thank you! iOS26 iOS18
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
160
3d
SwiftUI List optional refreshable
Currently refreshable modifier does not support nil as a value and there's no way of disabling refreshable without recreating the whole view. There are a few posts showing how refreshable could be optionally disabled on scrollViews using: \EnvironmentValues.refresh as? WritableKeyPath<EnvironmentValues, RefreshAction?> https://stackoverflow.com/a/77587703 However, this approach doesn't seem to work with Lists. Has anyone find any solutions for this?
0
0
138
3d
Source view disappearing when interrupting a zoom navigation transition
When I use the .zoom transition in a navigation stack, I get a glitch when interrupting the animation by swiping back before it completes. When doing this, the source view disappears. I can still tap it to trigger the navigation again, but its not visible on screen. This seems to be a regression in iOS 26, as it works as expected when testing on iOS 18. Has someone else seen this issue and found a workaround? Is it possible to disable interrupting the transition? Filed a feedback on the issue FB19601591 Screen recording: https://share.icloud.com/photos/04cio3fEcbR6u64PAgxuS2CLQ Example code @State var showDetail = false @Namespace var namespace var body: some View { NavigationStack { ScrollView { showDetailButton } .navigationTitle("Title") .navigationBarTitleDisplayMode(.inline) .navigationDestination(isPresented: $showDetail) { Text("Detail") .navigationTransition(.zoom(sourceID: "zoom", in: namespace)) } } } var showDetailButton: some View { Button { showDetail = true } label: { Text("Show detail") .padding() .background(.green) .matchedTransitionSource(id: "zoom", in: namespace) } } }
Topic: UI Frameworks SubTopic: SwiftUI
4
3
82
4d
macOS 26: retain cycle detected when navigation link label contains a Swift Chart
I'm running into an issue where my application will hang when switching tabs. The issue only seems to occur when I include a Swift Chart in a navigation label. The application does not hang If I replace the chart with a text field. This appears to only hang when running on macOS 26. When running on iOS (simulator) or visionOS (simulator, on-device) I do not observe a hang. The same code does not hang on macOS 15. Has any one seen this behavior? The use case is that my root view is a TabView where the first tab is a summary of events that have occurred. This summary is embedded in a NavigationStack and has a graph of events over the last week. I want the user to be able to click that graph to get additional information regarding the events (ie: a detail page or break down of events). Initially, the summary view loads fine and displays appropriately. However, when I switch to a different tab, the application will hang when I switch back to the summary view tab. In Xcode I see the following messages === AttributeGraph: cycle detected through attribute 162104 === === AttributeGraph: cycle detected through attribute 162104 === === AttributeGraph: cycle detected through attribute 162104 === === AttributeGraph: cycle detected through attribute 162104 === === AttributeGraph: cycle detected through attribute 162104 === A simple repro is the following import SwiftUI import Charts @main struct chart_cycle_reproApp: App { var body: some Scene { WindowGroup { TabView { Tab("Chart", systemImage: "chart.bar") { NavigationStack { NavigationLink { Text("this is an example of clicking the chart") } label: { Chart { BarMark( x: .value("date", "09/03"), y: .value("birds", 3) ) // additional marks trimmed } .frame(minHeight: 200, maxHeight: .infinity) } } } Tab("List", systemImage: "list.bullet") { Text("This is an example") } } } } }
0
0
125
4d
iOS26: `UITabAccessory` is both deeply inflexible and inconsistent
On iPhones: It will force the full width of the accessory view irrespective of its content Placing a view that manages its own glass – like a collection of individual glassy buttons – means that the full-width container is still encased in an outer layer of glass. There is no way to remove the outer glass layer, and it's not exposed as a property of a visual effect view, of the parent _UITabAccessoryContainer, or its parent _UITabBarContainerView. On iPads: Infuriatingly, it behaves completely different in regular width layouts. Suddenly, it doesn't draw a full width glass container around the content and starts respecting the supplied view's layout. A collection of glassy buttons starts working as intended. This all falls apart in compact layouts and starts behaving like an iPhone. The lack of configuration on this API is deeply unusual. More unusual is that there's no layout guide or similar for us to hook into to supply our own bottom accessory behavior.
Topic: UI Frameworks SubTopic: UIKit
0
0
98
4d
UIDocumentPickerViewController provides corrupt copy of file when user taps multiple times on file
We're trying to implement a backup/restore data feature in our business productivity iPad app using UIDocumentPickerViewController and AppleArchive, but discovered odd behavior of [UIDocumentPickerViewController initForOpeningContentTypes: asCopy:YES] when reading large archive files from a USB drive. We've duplicated this behavior with iPadOS 16.6.1 and 17.7 when building our app with Xcode 15.4 targeting minimum deployment of iPadOS 16. We haven't tested this with bleeding edge iPadOS 18. Here's our Objective-C code which presents the picker: NSArray* contentTypeArray = @[UTTypeAppleArchive]; UIDocumentPickerViewController* docPickerVC = [[UIDocumentPickerViewController alloc] initForOpeningContentTypes:contentTypeArray asCopy:YES]; docPickerVC.delegate = self; docPickerVC.allowsMultipleSelection = NO; docPickerVC.shouldShowFileExtensions = YES; docPickerVC.modalPresentationStyle = UIModalPresentationPopover; docPickerVC.popoverPresentationController.sourceView = self.view; [self presentViewController:docPickerVC animated:YES completion:nil]; The UIDocumentPickerViewController remains visible until the selected external archive file has been copied from the USB drive to the app's local tmp sandbox. This may take several seconds due to the slow access speed of the USB drive. During this time the UIDocumentPickerViewController does NOT disable its tableview rows displaying files found on the USB drive. Even the most patient user will tap the desired filename a second (or third or fourth) time since the user's initial tap appears to have been ignored by UIDocumentPickerViewController, which lacks sufficient UI feedback showing it's busy copying the selected file. When the user taps the file a second time, UIDocumentPickerViewController apparently begins to copy the archive file once again. The end result is a truncated copy of the selected file based on the time between taps. For instance, a 788 MB source archive may be copied as a 56 MB file. Here, the UIDocumentPickerDelegate receives a 56 MB file instead of the original 788 MB of data. Not surprisingly, AppleArchive fails to decrypt the local copy of the archive because it's missing data. Instead of failing gracefully, AppleArchive crashes in AAArchiveStreamClose() (see forums post 765102 for details). Does anyone know if there's a workaround for this strange behavior of UIDocumentPickerViewController?
9
0
888
4d
iOS26 UISearchbar and UISearchController cancellation issues
Is the Cancel button intentionally removed from UISearchBar (right side)? Even when using searchController with navigationItem also. showsCancelButton = true doesn’t display the cancel button. Also: When tapping the clear ("x") button inside the search field, the search is getting canceled, and searchBarCancelButtonClicked(_:) is triggered (Generally it should only clear text, not cancel search). If the search text is empty and I tap outside the search bar, the search is canceled. Also when I have tableview in my controller(like recent searches) below search bar and if I try to tap when editing started, action is not triggered(verified in sample too). Just cancellation is happening. In a split view controller, if the search is on the right side and I try to open the side panel, the search also gets canceled. Are these behaviors intentional changes, beta issues, or are we missing something in implementation?
5
0
213
4d
Resizing text to fit available space
My app displays some text that should appear the same regardless of the container view or window size, i.e. it should grow and shrink with the container view or window. On iOS there is UILabel.adjustsFontSizeToFitWidth but I couldn't find any equivalent API on macOS. On the internet some people suggest to iteratively set a smaller font size until the text fits the available space, but I thought there must be a more efficient solution. How does UILabel.adjustsFontSizeToFitWidth do it? My expectation was that setting a font's size to a fraction of the window width or height would do the trick, but when resizing the window I can see a slightly different portion of it. class ViewController: NSViewController { override func loadView() { view = MyView(frame: CGRect(x: 0, y: 0, width: 400, height: 400)) NSLayoutConstraint.activate([view.widthAnchor.constraint(equalTo: view.heightAnchor, multiplier: 3), view.heightAnchor.constraint(greaterThanOrEqualToConstant: 100)]) } } class MyView: NSView { let textField = NSTextField(labelWithString: String(repeating: "a b c d e f g h i j k l m n o p q r s t u v w x y z ", count: 2)) override init(frame frameRect: NSRect) { super.init(frame: frameRect) textField.translatesAutoresizingMaskIntoConstraints = false textField.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) addSubview(textField) NSLayoutConstraint.activate([textField.topAnchor.constraint(equalTo: topAnchor), textField.leadingAnchor.constraint(equalTo: leadingAnchor), textField.trailingAnchor.constraint(equalTo: trailingAnchor)]) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func resize(withOldSuperviewSize oldSize: NSSize) { // textField.font = .systemFont(ofSize: frame.width * 0.05) textField.font = .systemFont(ofSize: frame.height * 0.1) } }
Topic: UI Frameworks SubTopic: AppKit Tags:
7
0
109
4d
No dynamic guide available for the underlying `_UITabBarPlatterView`?
The new UITabBarController APIs are great! But they leave a lot to be desired. For example, let's say I want a bottom accessory – one simple enough that it could be a UIBarButtonItem. The UITabAccessoryAPI only takes UIViews but passing a simple UIVIew or UIButton will create a new problem: now the view is stretched to be huge instead of a tiny little image-button. New approach: Show it on screen as a contextual overlay modal thing. I can do that, no problem. New problem: It won't animate down when the tab bar minimizes, like the bottom accessory does; there is no layout guide exposed that allows us to hook into this. I'd really rather not reverse engineer to grab the platter when the state is minimized and set some funky layout constraints to adapt to it, determine that it can fit (a bit irrelevant in this instance, since it's a single button), and animate into place as the tab bar animates. I know there's a new contentLayoutGuide, but it doesn't seem there's anything like what I'm looking for here. I basically just want a tab accessory view, but I don't want to commit to it being so huge. And what happens if I want multiple views here? Suddenly, this opens up the toolbar, but… having a toolbar and a tab bar in the same app is an exercise in frustration, since the tab bar will cover up the toolbar. In a different environment, I may have gone ahead and just wrapped my own UITabBar, as Steve Troughton-Smith does via his Mastodon post (can't link directly). That presents another host of issues though: iPad behavior goes out the window. I'd probably still have to dig into private APIs to get a magic pocket effect that works the same as the UITabBarController's! UIScrollEdgeElementContainerInteraction doesn't behave exactly the same as the interaction added to the tab bar by the tab bar controller. Is there any such API for this? What possible reason could there be for keeping these APIs private?
Topic: UI Frameworks SubTopic: UIKit
0
0
77
4d
PressBegan() invoked twice when pressing Command + key on UITextView/UITextField
I am observing an unexpected behavior with external keyboard input on iOS. When I press Command + key (e.g., ⌘ + J) while a UITextView is focused, the system invokes pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) twice: -> Once with the key press event without any modifier flags. -> A second time with the same key event but including the Command modifier flag. This behavior is checked on an iPad with an external keyboard. Additionally, I noticed that textView(_:shouldChangeTextIn:replacementText:) is not invoked in this case, even if I call super.pressesBegan for event propagation. Questions: Is it expected that pressesBegan fires twice for a Command + key combination? If so, what is the recommended way to distinguish between these two invocations? Should the UITextView delegate methods (like shouldChangeTextIn) be triggered for such key combinations, or is this by design?
Topic: UI Frameworks SubTopic: UIKit Tags:
1
0
79
4d
HideAllTips launch argument does not work in xctestplan
The launch argument -com.apple.TipKit.HideAllTips 1 does not work if it is defined in xctestplan arguments passed on launch. I tested it with the apple provided example app, where I created simple UI test and added xctestplan with launch argument -com.apple.TipKit.HideAllTips 1. The app does not hide the tips when it is running the UI Tests. Is there any solution that works? Thanks for reply.
2
0
43
4d