For certain contexts, I'd like to still have my .sheet() be full width even when it's at a small height. In iOS 26, the sheet is inset from the edges at small detents and expands to full width at larger detents. For example, I have a view where I have a .sheet() that has a height of about 200pts and it contains a horizontally scrolling picker that extends past the bounds of the screen. I'd like the .sheet to expand all the way to the edge when at these small detents, like it would previous to iOS 26. Is it possible to configure this? This change will break a number of existing designs :(
A new ViewModifier such as
enum PresentationWidth {
case dynamic, fixed
}
func presentationWidth(_ width: PresentationWidth) -> some View
would be very nice.
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Posts under SwiftUI tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I want the effect of the model to be similar to the HoverEffect effect, but not by staring with the eyes. Instead, by clicking a button elsewhere, the corresponding model will appear highlighted,How can it be achieved
Hi,
I have an iPhone App with an UIWindowScene and two UIWindow's(mainWindow and alertWindow). In the mainWindow I have the whole app and it is allowed to rotate. The alertWindow is a window to show alert's to the user on the top of the screen and I do not want that the content inside rotate.
I thought I may do:
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
And
override var shouldAutorotate: Bool {
return false
}
In the rootviewcontroller of alertWindow but after doing those changes the rootviewcontroller of mainWindow does not rotate until I do any navigation.
I have thought to have two UIWindowScene's (one per UIWindow) but as far I know iPhone app only supports one UIWindowScene.
So, how can I avoid rotation in the viewcontroller of alertWindow without losing the rotation on rootviewcontroller of mainWindow?
My viewcontroller is a UIHostingController, so I tried also to avoid from my SwiftUI view but I did not find any solution neither.
Thank you in advance
A document-based app with NavigationSplitView shows duplicate file navigation controls on iPad.
This can be easily replicated by creating a multiplatform app in Xcode. The template app shows this behaviour when running on iPad.
This looks very much like a bug.
I'm using ViewThatFits to handle different screen sizes as well as the orientation of the phone. Essentially, I have a smaller view that should only be used in portrait mode on the phone and a larger view that should be used in every other instance.
The issue is that both of those views have a Text view that is bound to a String within a SwiftData model.
If the String is too long the ViewThatFits considers that when choosing the appropriate subview. This results in a list of items where most items use one view while one or more may use the other view.
It would be great if there was a modifier that could be applied to the Text view that resulted in the ViewThatFits ignoring it when determining the appropriate subview.
Until such a modifier is available, has anyone come up with creative ways around this?
Is there a way to detect when your apps (or any app I guess) is being moved by the user clicking and dragging the main window around the desktop at all?
I'm trying to find out if there's a way I can find out if a window is being clicked and dragged and whether there's certain triggers to the movement a little bit like shaking an iPhone with Shake to Undo.
Thanks
I'm trying to display my apps icon within my app and it's not working. It displays a blank space instead and I don't understand why this is happening.
I tried creating a new image (just a normal image, not an 'App Icon' image set) and have this code:
Image("AppIcon")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 48)
.cornerRadius(10)
.overlay(
RoundedRectangle(cornerRadius: 10)
.stroke(Color.black.opacity(0.1), lineWidth: 1)
)
For some strange reason it's not displaying that either. The image name is correct. It's showing a blank white box.
I have a memory leak for SVG image that located in Assets.xcassets file when using SwiftUI Image, but when I use UIImage then convert it to SwiftUI Image the issue is not found.
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
VStack {
NavigationLink("Show", destination: SecondView())
}
.padding()
}
}
}
struct SecondView: View {
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
VStack {
IM.svgImage
.resizable()
.scaledToFit()
.frame(width: 200, height: 200)
Button("Dismiss") {
dismiss()
}
}
}
}
}
enum IM {
static let testImage: Image = "test_image".image
static let svgImage: Image = "svgImage".image
}
extension String {
var image: Image {
Image(self) // Memory leak
}
var imageFromUIImage: Image {
guard let uiImage = UIImage(named: self) else {
return Image(self)
}
return Image(uiImage: uiImage) // No Memory leak
}
}
Environment that produces the issue:
Xcode: 16.2
Simulator: iPhone 15 Pro (iOS 17.5)
Hi,
Anybody knows will this occurs when using navigationStack at iOS 18.3? The navigationStack not stay at safeareas
the code as simple as that:
NavigationStack(path: $navManager.path) {
VStack {
Text("Hello")
}
.navigationDestination(for: Route.self) { route in
switch route {
....
}
}
}
.environmentObject(navManager)
.environment(logic)
When I update a variable inside my model that is marked @Transient, my view does not update with this change. Is this normal? If I update a non-transient variable inside the model at the same time that I update the transient one, then both changes are propagated to my view.
Here is an example of the model:
@Model public class WaterData {
public var target: Double = 3000
@Transient public var samples: [HKQuantitySample] = []
}
Updating samples only does not propagate to my view.
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!
In SwiftUI, a link is identified as both a button and link, this is during when running with VoiceOver.
I know you can remove the button trait using .accessibilityRemoveTraits.
However, I am sure there is a reason to it.
Can somebody explain if it is genuinely a bug.
Basically when showing a view using the .fullScreenCover modifier, it has no background anymore, any other UI elements are still shown but the view under it is also still shown.
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’m trying to add a TextField to the toolbar using .principal placement, and I want it to either fill the screen width or expand based on the surrounding content. However, it’s not resizing as expected — the TextField only resizes correctly when I provide a hardcoded width value. This behavior was working fine in previous versions of Xcode, but seems to be broken in Xcode 26. Not sure if this is an intentional change or a bug. i am using iOS26 beta and Xcode 26 beta
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
}
.padding()
.toolbar {
ToolbarItem(placement: .principal) {
HStack {
TextField("Search", text: .constant(""))
.textFieldStyle(.roundedBorder)
.frame(maxWidth: .infinity)
// .frame(width: 300)
Button("cancel") {
}
}
.frame(maxWidth: .infinity)
}
}
}
}
#Preview {
NavigationView {
ContentView()
}
}
Dear all,
The Search fields documentation appears to make a distinction between putting a search in a tab bar and in a bottom toolbar in an iOS device.
Putting a search in a tab bar in iOS26 appears to be quick and easy:
Tab(role: .search) {
// Search
}
I cannot find, however, a way on how to put a search bar in a bottom toolbar (as illustrated here). The following code puts it in the top toolbar:
.searchable(text: $searchQuery, placement: .toolbar)
Same as this one:
.searchable(text: $searchQuery, placement: .toolbarPrincipal)
Do I miss something in this regard?
Thanks!
Hi y'all!
I'm creating an iOS app with SwiftUI. Part of the app's layout will have a toolbar.
Per the HIG's Toolbar article, under the section titled "Actions", the primary action in the toolbar should use the .prominent modifier.
Unfortunately, I'm having issues finding information about this modifier in the SwiftUI reference documentation, and Xcode's code completion (the standard completions; I don't use the language model version) doesn't reveal anything that seems to be usable to create the desired effect.
For reference, this is what the view currently looks like:
VStack {
}
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Add Something", systemImage: "plus") {
print("perform action")
}
}
}
Is this modifier added to the button itself as .buttonStyle(.borderedProminent)? This seems to create an odd off-center layout shift in the Xcode preview, the Simulator, and my physical device. Is it added to the toolbar item with a similarly-named modifier?
Thanks all! :)
When using a .zoom navigation transition, where .matchedTransitionSource is applied to a button in a toolbar and the destination view is a sheet which is presented with PresentationDetent.medium, the transition works initially, but shortly after it completes, the sheet's background is dimmed and the text of the source button reappears abruptly.
Code and a screenshot are below, though the effect is best observed when interacting with the view.
//
// ContentView.swift
// ZoomNavigationTransitionSample
//
// Created by Matthew DuBois on 6/15/25.
//
import SwiftUI
struct ContentView: View {
@State private var isPresentingSheet = false
@Namespace private var namespace
var body: some View {
NavigationStack {
List {
Text("Some content")
}
.navigationTitle("Sample")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Button") {
isPresentingSheet = true
}
.matchedTransitionSource(id: "button", in: namespace)
}
}
.sheet(isPresented: $isPresentingSheet) {
Text("Some sheet content")
.navigationTransition(.zoom(sourceID: "button", in: namespace))
.presentationDetents([.medium])
}
}
}
}
#Preview {
ContentView()
}
Is SFSymbol Customization officially valid as a method for using SVG in embedded widgets (lock-screen & watchOS)?
I use this in UnitedPizzaHelper but wonder whether this is the prime cause why all widgets of this app gets missing on iOS devices? This issue only happened on at least 2 device in the recent 12 months (they are all on iOS 18, and one of them is running iOS 18.5... Rebooting device won't work.), and we currently have no clue how to troubleshoot this.
Update: The guy running iOS 18.5 told me that the widgets are now discoverable after waiting for minutes. Seems that this is a random issue.
What is the recommended way to attach SwiftUI views to RealityKit entities on macOS, iOS, etc?
All the APIs seem to be visionOS only:
https://developer.apple.com/documentation/realitykit/realityviewattachments
https://developer.apple.com/documentation/realitykit/viewattachmentcomponent
https://developer.apple.com/documentation/realitykit/presentationcomponent
https://developer.apple.com/documentation/realitykit/imagepresentationcomponent
My only idea is to do it "manually" with a ZStack and RealityView somehow?
I submitted this as a feedback since it seemed like an oversight: FB18034856.