Our app displays complex, data-driven layouts that can display grids of items in addition to full width rows (essentially, nested lists). We'd like to be able to preserve cell/item portability (i.e., display in any content strip) and allow them to carry capabilities like swipe actions. In UIKit we have features in compositional layout that allow for this. However, in SwiftUI the only support seems to be at the List level.
Nesting a List within a ScrollView to get swipe actions feels like a dark road. We've rolled our own swipe actions system, but we'd much rather use a native solution. Any other options here?
Improvement ticket here FB17994843.
How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Posts under SwiftUI tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
The inspector(isPresented:content:) modifier is not available on visionOS while the InspectorCommands struct is marked available on visionOS.
Should inspector work on visionOS as well or is this an oversight?
I have a floating action button in my app above a toolbar. The action button adds items to my app, so is pretty important and should be easy to reach. Now with the new liquid glass design, I wonder what the best way is to combine those two.
Should I use .tabViewBottomAccessory() for that? Though, that will merge down on scroll. 🤔
Or can I replace the search button in the bottom right with my own custom button action?
How can I achieve the result of buttons glass effect like sample videos that was show at de WWDC25? I tried a lot of approaches and I still far a way from the video.
I would like something like the pictures attached. Could send a sample code the get the same result?
Thanks
I'd like to support different template views within a ViewThatFits for items within a list, allowing the list to optimize its layout for different devices.
Within the child views is a Text view that is bound to the name of an item. I'd rather the Text view simply truncate the text as necessary although it instead is influencing which view is chosen by ViewThatFits. I'd also rather not artificially set the maxWidth of the Text view as it artificially limits the width on devices where it's not necessary (e.g. iPad Pro vs. iPad mini or iPhone).
Any guidance or suggestions on how this can be accomplished as it looks very odd for the layout of one row in the list to be quite different than the rest of the rows.
Navigation Title no longer showing for first Tab in iOS/iPadOS 26 (Directives) in my app Starship SE Corps when running is Xcode 26 simulator and on iPad device itself running iPadOS 26 beta.
Launch app
Notice Navigation Title “Directives” is missing from top tab in Sidebar and Floating Tab View (iPad) and TabView (iOS).
Navigate to other tabs and Navigation Titles appear as expected.
Worked fine (as expected) in iOS/iPadOS 18.5, but broken in iOS/iPadOS 26.
Reference Feedback: FB17987650
I’ve noticed with the new design language, SwiftUI views appear to not use color as much. Example, color modifiers for List View items like carets. Is this intended and can developers introduce color back into SwiftUI view elements, if desired, like in iOS/iPadOS 18?
Specifically, accent color not been used in List disclosure outline carets.
Does the new TextEditor in iOS 26, which supports rich text / AttributedString, also support the ability to add text attachments or tokens? For example, in Xcode, we can type <#foo#> to create an inline text placeholder/token which can be interacted with in a different way than standard text.
Dear all,
The scroll to top functionality of the tabItem does not scroll to the actual top of the view, when a list / scrollView is embedded in a tabView. Tapping the tabItem brings the view to the mid-point of the navigationTitle, leaving the navigationTitle half-blurred in the new iOS26:
I believe that the same issue was present in previous iOS versions as well.
Do you experience the same problem, or am I doing something wrong? The code is below.
var body: some View {
TabView {
NavigationStack {
List {
ForEach(0..<100) { i in
Text(i.formatted())
}
}
.navigationBarTitleDisplayMode(.large)
.navigationTitle("List")
}
.tabItem {
Label("List", systemImage: "list") // Tapping here while the list is scrolled down does not bring the entire list to the actual top
}
}
}
}
Like this
Here's my code
Hey,
The new "soft" scroll edge effect is really cool! But it seems to only appear when you add toolbar items.
Is there a way to add it for "custom" views as well, that I place in a safe area inset?
For example, the messages app in iOS 26 does this. There's a text field as a safe area inset as well as a soft scroll edge effect.
Thanks!
Prior to visionOS 2.5, .onTapGesture was called with the following structure, but in visionOS 26.0 beta, it is no longer called.
Is .onTapGesture deprecated in visionOS 26.0 and above? Or is it a bug?
TabView(selection: $selectedTab) {
WebViewView(selectedTab: $selectedTab)
.onTapGesture {
viewModel.userDidInteract = true
}
}
I am trying out the new AttributedString binding with SwiftUI’s TextEditor in iOS26. I need to save this to a Core Data database. Core Data has no AttributedString type, so I set the type of the field to “Transformable”, give it a custom class of NSAttributedString, and set the transformer to NSSecureUnarchiveFromData
When I try to save, I first convert the Swift AttributedString to NSAttributedString, and then save the context. Unfortunately I get this error when saving the context, and the save isn't persisted:
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x600003721140> , <shared NSSecureUnarchiveFromData transformer> threw while encoding a value. with userInfo of (null)
Here's the code that tries to save the attributed string:
struct AttributedDetailView: View {
@ObservedObject var item: Item
@State private var notesText = AttributedString()
var body: some View {
VStack {
TextEditor(text: $notesText)
.padding()
.onChange(of: notesText) {
item.attributedString = NSAttributedString(notesText)
}
}
.onAppear {
if let nsattributed = item.attributedString {
notesText = AttributedString(nsattributed)
} else {
notesText = ""
}
}
.task {
item.attributedString = NSAttributedString(notesText)
do {
try item.managedObjectContext?.save()
} catch {
print("core data save error = \(error)")
}
}
}
}
This is the attribute setup in the Core Data model editor:
Is there a workaround for this?
I filed FB17943846 if someone can take a look.
Thanks.
Is the new Observations API for WebPage not available in Beta 1 as demoed in the WWDC video? I get this error even though Observation is imported.
Hi,
On iOS, I'd like to mark views that are inside a LazyVStack as headers for VoiceOver (make them appear in the headings rotor).
In a VStack, you just have add .accessibilityAddTraits(.isHeader) to your header view. However, if your view is in a LazyVStack, that won't work if the view is not visible. As its name implies, LazyVStack is lazy so that makes sense.
There is very little information online about system rotors, but it seems you are supposed to use .accessibilityRotor() with the headings system rotor (.accessibilityRotor(.headings)) outside of the LazyVStack. Something like the following.
.accessibilityRotor(.headings) {
ForEach(entries) { entry in
// entry.id must be the same as the id of the SwiftUI view it is about
AccessibilityRotorEntry(entry.name, id: entry.id)
}
}
It kinds of work, but only kind of. When using .accessibilityAddTraits(.isHeader) in a VStack, the view is in the headings rotor as soon as you change screen. However, when using .accessibilityRotor(.headings), the headers (headings?) are not in the headings rotor at the time the screen appears. You have to move the accessibility focus inside the screen before your headers show up.
I'm a beginner in regards to VoiceOver, so I don't know how a blind user used to VoiceOver would perceive this, but it feels to me that having to move the focus before the headers are in the headings rotor would mean some users would miss them.
So my question is: is there a way to have headers inside a LazyVStack (and are not necessarily visible at first) to be in the headings rotor as soon as the screen appears? (be it using .accessibilityRotor(.headings) or anything else)
The "SwiftUI Accessibility: Beyond the basics" talk from WWDC 2021 mentions custom rotors, not system rotors, but that should be close enough. It mentions that for accessibilityRotor to work properly it has to be applied on an accessibility container, so just in case I tried to move my .accessibilityRotor(.headings) to multiple places, with and without the accessibilityElement(children: .contain) modifier, but that did not seem to change the behavior (and I could not understand why accessibilityRotor could not automatically make the view it is applied on an accessibility container if needed).
Also, a related question: when using .accessibilityRotor(.headings) on a screen, is it fine to mix uses of .accessibilityRotor(.headings) and .accessibilityRotor(.headings)? In a screen with multiple type of contents (something like ScrollView { VStack { MyHeader(); LazyVStack { /* some content */ }; LazyVStack { /* something else */ } } }), having to declare all headers in one place would make code reusability harder.
Thanks
Dear all,
Is it possible to replace the default PDF background colour the 50% grey to any other colour while using the new WebView? Using the standard .background method on WebView does not appear to have any effect:
WebView(pdfWebpage)
.background(Color.blue) // no effect on the background of the PDF
Thanks!
This modifier in visionOS 2.5 works perfectly with LazyVgrid inside a Stack in ScrollView:
.hoverEffect { effect, isActive, _ in
effect.scaleEffect(isActive ? 1.1 : 1.0)
But the grid does not scroll in visionOS 26 beta 1 unless the scaleEffect is commented out.
FB17941468
Hi, I have a SwiftUI View, that is attached to a 3D object in Reality View. This is supposed to be a HUD for the user to select a few things. I wanted a sub menu for one of the top level buttons.
But looks like none of the reasonable choices like Menu, Sheet or Popover work.
Is there a known limitation of RealityKit Views where full SwiftUI cannot be used? Or am I doing something wrong?
For example,
Button {
SLogger.info("Toggled")
withAnimation {
showHudPositionMenu.toggle()
}
} label: {
HStack {
Image(systemName: "rectangle.3.group")
Text("My Button")
}
}
.popover(isPresented: $showHudPositionMenu, attachmentAnchor: attachmentAnchor) {
HudPositionMenuItems(showHudPositionMenu: $showHudPositionMenu, currentHudPosition: $currentHudPosition)
}
This will print "Toggled" but will not display the MenuItems Popover.
If it makes any difference, this is attached to a child of a head tracked entity.
.glassEffect(.regular, in: .rect(cornerRadius: 24))
error; 'glassEffect(_:in:isEnabled:)' is unavailable in visionOS
This is not surprising since visionOS already has a native glass interface that formed a model for the other OS's, but this error will create additional overhead for developers creating multi-platform apps that include visionOS.
Since only the user can take a screenshot using the Apple Vision Pro's top buttons, the only workaround available to an immersive app that needs a screenshot to document the user's creative interior design choices is
ask the user to take a screenshot
wait until the user taps a button indicating the screenshot has been taken
then the app asks the user to select the screenshot when the app opens the PhotoPicker
when the user presses Done, the screenshot is handed off to the app.
One wonders why there is no Apple Api for doing this in a simple privacy protective way such as:
When called, the Apple api captures the screenshot in Apple secured memory
The api displays the screenshot to the user with appropriate privacy warnings and asks if the user wants to
a. share this screenshot with the app, or
b. cancel,
c. retake the screenshot
If the user approves, the app receives the screenshot