We ran into a bug with our app Bezel (https://getbezel.app). When running on macOS Tahoe, windows would get partially clipped.
This is because we have SwiftUI views that are larger than the window size, our SwiftUI views are supposed to be centered, which they are on macOS 13, 14, 15. But on macOS 26 (beta 1), the window contents are top-left aligned.
This seems to be a bug, I have submitted FB18201269.
This is my code:
WindowGroup {
ZStack {
Color.green
ZStack {
Color.yellow
Text("Hi")
}
.aspectRatio(1, contentMode: .fill)
.border(.red)
}
}
This first screenshot shows the old behavior on macOS 15:
This second screenshot shows the new behavior on macOS 26 (beta 1)
Can anyone confirm if this is indeed a bug, or if this an intended change in behavior?
SwiftUI
RSS for tagProvide views, controls, and layout structures for declaring your app's user interface using SwiftUI.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
On iOS 18, while on a modal screen, if the scrolling starts on a button, that button gets pressed, outside of a modal this doesn't reproduce, also not reproducible on older iOS versions, neither on modals or outside of them.
The code to reproduce the issue:
import SwiftUI
struct ContentView: View {
@State var presentModal = false
var body: some View {
Button(action: {
presentModal = true
}, label: {
Text("open modal")
})
.sheet(isPresented: $presentModal, content: {
ScrollView {
ForEach(0..<100, id: \.self) { index in
Button(action: {
print("Button \(index) tapped!")
}) {
Text("Button \(index)")
.frame(maxWidth: .infinity)
.frame(height: 100)
.background(randomColor(for: index))
.padding(.horizontal)
}
}
}
})
}
func randomColor(for index: Int) -> Color {
let hue = Double(index % 100) / 100.0
return Color(hue: hue, saturation: 0.8, brightness: 0.8)
}
}
#Preview {
ContentView()
}
Hi! I'm working on a iOS 26 SwiftUI prototype that adds an element to the content of a screen only when the tab bar is fully visible and not minimized (via .tabBarMinimizeBehavior).
Is there any way to detect when a tab bar is minimized? My hope is that I can use a ternary operator to display something only when a boolean is true.
Here's some code to illustrate my idea:
struct ContentView: View {
@State var isTabBarMinimized: Bool = false
var body: some View {
TabView {
Tab("View1", systemImage: "rainbow") {
// Only appears when tab bar is fully visible
Color.blue
.opacity(isTabBarMinimized? 0 : 1 )
}
Tab("View2", systemImage: "rainbow") {
View2()
}
Tab("View3", systemImage: "rainbow") {
View3()
}
Tab("View4", systemImage: "rainbow") {
View4()
}
}
.tabBarMinimizeBehavior(.onScrollDown)
}
}
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.
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
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.
How can I create a view that is like the one in the Photos app where you can select an item and it fills the window, then you can drag / swipe between items in that view? I have a working prototype, and it works for photos. But once I get to a video, the gesture no longer works.
I can only find example on how to use onScrollTargetVisibilityChange for ScrollViews.
Is there any way I can use this modifier for Lists as well?
List {}.onScrollTargetVisibilityChange ( ... ) is not working for me :(
Topic:
UI Frameworks
SubTopic:
SwiftUI
Is anyone familiar with AppIntents and their usage?
I have an AppIntent defined in my widget extension.
I have the same AppIntent defined in the app marked as ForegroundContinuableIntent.
If I add the intent on a SwiftUI button and tap the Button it correctly resolves the app's version of the intent and performs that intent.
However, what I really want to do is perform the AppIntent manually as the timeline updates but not more often than every hour (i.e. >= 1 hour).
It's easy enough to handle the timing in the timeline. However, I do not know how to resolve the intent such that it calls the app's version of the intent (i.e. the same way that a Button does). If I just call perform it will run the version in the widget extension.
The end goal is to minimally / periodically sync with the app.
Thanks in advance for any help / advice on this.
Topic:
UI Frameworks
SubTopic:
SwiftUI
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?
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)
I'm making a macOS app using SwiftUI and I would like to minimise (hide) all open windows when I click a button.
Is this possible with SwiftUI and if so, how would I go about implementing this? Thanks
Topic:
UI Frameworks
SubTopic:
SwiftUI
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.
Is there a way to share a SwiftUI App's @Observable model into a CPTemplateApplicationSceneDelegate ?
Is there an incantation to go from the UIApplicationDelegate via @UIApplicationDelegateAdaptor to the UISceneDelegate for CarPlay via a userInfo? I can't seem to figure it out.
Otherwise I have to use a shared global, and I'd prefer not to have to do it this way. Any ideas? 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!
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.
I am curious if the new WebView and WebPage APIs have a way to programmatically set if the web page should be shown in Reader Mode like you could with SFSafariViewController. I did not see a way to do this, but I'm curious if I may be missing something.
In WWDC 25's session Get to Know the Design system, Maria mentions that corner radius should match it's parent view or the iPhone's corners if its the outermost view. Rather than trying to figure out what number to pass into .cornerRadius(15), why not have a .roundedCorner modifier and have the system do this geometry work?
See my feedback also FB17947241
Topic:
UI Frameworks
SubTopic:
SwiftUI