Search results for

“swiftui”

17,109 results found

Post

Replies

Boosts

Views

Activity

How can I reliably get the final restored window size on macOS when onAppear / viewDidAppear fires too early?
I’m running into a macOS window restoration behavior issue where viewDidAppear (AppKit) or onAppear (SwiftUI) fires before the window’s final restored size is applied. AppKit example class MyViewController: NSViewController { override func viewDidLayout() { print(viewDidLayout: (view.bounds.size)) } override func viewDidAppear() { print(viewDidAppear: (view.bounds.size)) } } Logs on launch: viewDidAppear: (480.0, 270.0) viewDidLayout: (480.0, 270.0) viewDidLayout: (556.0, 476.0) viewDidLayout: (556.0, 476.0) The correct restored size is (556.0, 476.0), but viewDidAppear initially reports the old default size (480.0, 270.0). SwiftUI equivalent struct MyView: View { var body: some View { GeometryReader { geo in VStack {} .onAppear { print(onAppear: (geo.size)) } .onChange(of: geo.size) { print(onChange: (geo.size)) } } } } Logs on launch: onAppear: (900.0, 450.0) onChange: (680.0, 658.0) Problem I need to run some setup code: Only once After the view/window has its correct restored size Withou
3
0
319
4w
CLLocationManager permission prompt never appears in Swift Playground
I am building a Swift Playgrounds App project on iPad running iPadOS 26.0.1 using the latest version of Swift Playgrounds. I need to access Core Location for a plant location logging app. What I have done: • Created an App project (not a Playground) in Swift Playgrounds • Enabled ‘Core Location When in Use’ in the app capabilities (accessed by tapping the app name) • Implemented a CLLocationManager with CLLocationManagerDelegate • Called manager.requestWhenInUseAuthorization() from .onAppear in a SwiftUI view • Called manager.startUpdatingLocation() immediately after The problem: The location permission prompt never appears when the app runs. The app does not appear in Settings → Privacy & Security → Location Services at all. There are no error messages or crashes — the app simply never requests location access. What I have ruled out: • The capability IS enabled in Swift Playgrounds app settings • The app runs without errors otherwise • This is an App project, not a classic Playground, so it shou
3
0
314
4w
Reply to SwiftUI TextField.accessibilityIdentifier is not propagated to the underlying UITextField instance.
Hello @Divyashruti, Thank you for your question. SwiftUI views do not necessarily map 1-to-1 to UIKit UIView classes, and so you should not rely on framework calls based on that assumption. Couldn't you stick to using SwiftUI modifiers, such as onChange(of:initial:_:), or use custom bindings? Hoping this helps, Richard Yeh  Developer Technical Support
Topic: UI Frameworks SubTopic: SwiftUI Tags:
4w
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
Thanks for the post, and great UI in my opinion. Hope as many SwiftUI people jump into this thread but I think the issue is because you are using UIKit. I think based on the error message, the error you are seeing is a UIKit presentation issue when a UI isn’t finished so looks like .palette control group style on iOS is backed by UIKit's context menu system (UIContextMenuInteraction). https://developer.apple.com/documentation/uikit/uicontextmenuinteraction When the menu is open, a private view controller (_UIContextMenuActionsOnlyViewController) is actively being presented. I think the issue here is as UIKit strictly enforces that a UIViewController can only present one view controller at a time, but you call to present(...) fails because the underlying navigation controller is still busy presenting the context menu? Is it timing the issue? If possible, you should avoid calling UIKit's present() manually from a SwiftUI button action. Instead, update a @State or @Published property in your vi
Topic: UI Frameworks SubTopic: UIKit Tags:
4w
ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
When I set up a toolbar item group with multiple options and set the controlGroupStyle as .palette, and when one of the options are supposed to present a view controller, I get the following error Attempt to present on (from ) which is already presenting <_UIContextMenuActionsOnlyViewController: 0x1035c19d0>. So basically the context menu we see is under the hood a view controller that is being presented. Is there a right way of fixing it, or is it maybe something that will be fixed by Apple? This is how I set up the ToolbarItemGroup on SwiftUI and the view model ultimately presents another UINavigationController that has a UIHostingController as its view controller: .toolbar { ToolbarItemGroup(placement: .topBarTrailing) { Button(ft_commons_edit.localised, systemImage: pencil) { viewModel.didTapEditAction() } Button(ft_commons_delete.localised, systemImage: trash) { viewModel.didTapDeleteAction() } } label: { Image(edit-icon) .resizable() .frame(width: 24.0, height: 24.0) } } .controlGroupSt
6
0
398
4w
SwiftUI TextField.accessibilityIdentifier is not propagated to the underlying UITextField instance.
When applying the .accessibilityIdentifier(_:) modifier to a SwiftUI TextField, the identifier is correctly added to the SwiftUI Accessibility Tree (visible in Accessibility Inspector), but it is not assigned to the accessibilityIdentifier property of the underlying UITextField instance. This causes issues for developers who monitor global notifications, such as UITextField.textDidChangeNotification. When a notification is received, the object (the UITextField) has a nil identifier, making it impossible to programmatically determine which specific text field triggered the event. Steps to Reproduce: Create a SwiftUI view containing a TextField. Apply .accessibilityIdentifier(TargetTextField) to that TextField. Set up an observer (via NotificationCenter or onReceive) for UITextField.textDidChangeNotification. Run the app and type into the text field. Inspect the accessibilityIdentifier property of the UITextField object provided by the notification. Expected Result: The UITextField.ac
1
0
258
Apr ’26
NSTextAttachment view flicker while typing in same paragraph
I using SwiftUI to wrap a NSTextView to support rich text editing. I created a subclass ImageAttachment and provided my own viewProvider and attachmentView. The insertion of the image works fine, but when I typing in the same paragraph of the image, the image will flicker during typing and pause. after typing it sometimes just display nothing, but after refresh or click other places, the image shows. The interesting part is if I typing in other paragraph, the image attachment displays well. I don't think the flicker should happen while typing in the same paragraph of the attachment, but not sure if there is a way to enforce the layout stable for the paragraph?
Topic: UI Frameworks SubTopic: AppKit
1
0
209
Apr ’26
Timing issue with updating two state variables
I have a SwiftUI view with: @State var url: URL? @State var isShowingBrowser: Bool func displayURL(url: URL) { self.url = url self.isShowingBrowser = true } var body: some View { Group { // ...... } .sheet(isPresented: $isShowingBrowser) { // browser view } } The first time I call displayBrowser, an empty browser sheet appears, with no URL. The second time, it works. It doesn't matter if I reorder the assignments in displayURL. It's like the view refreshes once with a nil URL and isShowingBrowser true, then refreshes again with the URL value. If I move both variable to an @Observable view model class then it works fine - that update seems to happen atomically. For my own project, the view model is the right way to do this, but I was confused by this behavior. What am I missing about SwiftUI?
Topic: UI Frameworks SubTopic: SwiftUI
0
0
211
Apr ’26
Reply to LLDB `po`/`v` commands fail in new iOS project
Thanks for the post. The latest Xcode is 26.4.1 and I just used po without any issue. On your screenshot it looks like you are on SwiftUI currently inside the View? If your fresh project is a SwiftUI app and you are placing your breakpoint directly inside the var body: some View block, LLDB frequently fails to evaluate variables. This is because the body is a ViewBuilder, and the complex generic type inference often breaks the LLDB expression evaluator. Try placing a breakpoint inside a standard function (like func test() { let x = 5 }) or an .onAppear { ... } modifier. If po works there but not in the body. It looks like you also tried v? It is your best friend in SwiftUI. po compiles code to evaluate the object. v bypasses the compiler entirely and reads the variable directly from memory. If you have a breakpoint inside your SwiftUI view, type v myVariable instead of po myVariable. It is significantly faster and works in many SwiftUI contexts where po fails. I li
Apr ’26
UITabBar (Liquid Glass) rendering breaks when UITabBarController is recreated while fully obscured by a fullscreen modal
I’m seeing a rendering issue with UITabBarController on iOS 26 (Liquid Glass), and I’d like to confirm whether others can reproduce this or have a workaround. Summary If a UITabBarController is recreated while it is fully hidden behind a fullscreen modal, the tab bar renders incorrectly after dismissal. Selected tab becomes nearly invisible Unselected tabs appear to show both selected and unselected tint colors Looks like multiple rendering states are composited incorrectly This only happens with: iOS 26 (Liquid Glass enabled) UIKit UITabBarController It does not reproduce with SwiftUI TabView. Minimal Reproduction Code This is a complete, minimal example: import UIKit // MARK: - Root class RootViewController: UIViewController { private var tabBar: UITabBarController? private var modalPresented = false override func viewDidLoad() { super.viewDidLoad() installTabBar() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) // Present once on first appear, simulating an app-laun
1
0
165
Apr ’26
Misleading error on ForEach
During refactoring of an app I made a typo which leads to a misleading error message in Xcode 26.4. I could reproduce it with a small sample code in Swift Playground. Is it a bug which should be reported? Details: I have an array containing two strings. Using a ForEach loop is fine: ForEach(appData.dataArray, id: .self) { value in Text((value.subject)t(value.room)) } but with a typo in the Text line I got an error on the ForEach line: ForEach(appData.dataArray, id: .self) { value in --> Cannot convert value of type '[MyArray]' to expected argument type 'Binding' Text((value.subject)t(value.subject.room)) } Complete sample code from Swift Playground (macOS 26): import SwiftUI class MyArray : Hashable, Equatable, Identifiable, ObservableObject, Codable { let id = UUID() @Published var subject: String @Published var room : String private enum CodingKeys : String, CodingKey { case subject case room } init(subject : String, room : String) { self.subject = subject self.room = room } func encode(to encod
2
0
1.5k
Apr ’26
Reply to SwiftUI Text rendering with too small height / one line missing causing unexpected text truncation on iPhone devices
The iPhone 15 screen is big enough. Adding a ScrollView doesn't fix this. The problem isn't that there's not enough size being proposed / available to the Text. The problem is that Text internally calculates the needed number of lines wrongly and then takes on a size with a slightly too small height. I agree with your assessment that the issue is a bug on Text. I saw a similar issue in an app with larger text block, and wrapping the Text with ScrollView had the Text expand to the size a bit higher than the height it calculates, which happened to fix the issue. I can't reproduce the issue your described with my iPhone 15 Simulator + iOS 26.4 (23E244), and so can't verify if the workaround helps in your case, but good to know that it doesn't. In this situation, the only thing I can see is to switch to UITextView + UIViewRepresentable, which is not a pure SwiftUI way and is probably not your choice. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’26
'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
Hi, Overview: I get the following error when trying to save / read from SwiftData It happens when I try to save color to SwiftData (code below) Error 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release Questions How can I resolve the error? I am not directly using data, I am using just Float values, swift types. Why am I getting this error? Is there a way to add a breakpoint to stop at the exact type causing the error? (Symbolic breakpoint doesn't seem to help) Or is the below code ok and not responsible for the error? Code import SwiftUI nonisolated struct ColorRepresentation: Codable { let red: Float let green: Float let blue: Float let opacity: Float init(colorResolved: Color.Resolved) { red = colorResolved.red green = colorResolved.green blue = colorResolved.blue opacity = colorResolved.opacity } func color() throws -> Color { Color( red: Double(red), green: Double(green), blue: Double(blue), opacity: Double(opacity) ) } } extension ColorRe
9
0
511
Apr ’26
.buttonStyle(.glass) background changes abruptly between 50pt and 51pt in dark mode
[Submitted as FB22612121] A SwiftUI Button using .buttonStyle(.glass) with .buttonBorderShape(.capsule) changes its background abruptly when its size goes from 50×50 to 51×51 points in dark mode. This appears to be a threshold in opacity/material rather than a smooth size-based change. The sample shows identical buttons at 40, 50, 51, and 60 points, with a clear jump between 50 and 51. Measured RGB values shift from 19,19,19 to 30,30,30. The effect also varies with the background, which points to a material/opacity change rather than a fixed fill. ENVIRONMENT iOS 26.4.1 (23E254a) iOS 26.5 (23F5059e) REPRO STEPS Create a new iOS SwiftUI project. Replace ContentView with the sample code below. Run the app or open ContentView in SwiftUI Preview (dark mode). Observe the buttons at 40×40, 50×50, 51×51, and 60×60. Compare the 50pt and 51pt buttons. ACTUAL The background changes abruptly between 50pt and 51pt. The 51pt button uses a noticeably different opacity/material, producing a visibl
Topic: UI Frameworks SubTopic: SwiftUI
1
0
222
Apr ’26
How can I reliably get the final restored window size on macOS when onAppear / viewDidAppear fires too early?
I’m running into a macOS window restoration behavior issue where viewDidAppear (AppKit) or onAppear (SwiftUI) fires before the window’s final restored size is applied. AppKit example class MyViewController: NSViewController { override func viewDidLayout() { print(viewDidLayout: (view.bounds.size)) } override func viewDidAppear() { print(viewDidAppear: (view.bounds.size)) } } Logs on launch: viewDidAppear: (480.0, 270.0) viewDidLayout: (480.0, 270.0) viewDidLayout: (556.0, 476.0) viewDidLayout: (556.0, 476.0) The correct restored size is (556.0, 476.0), but viewDidAppear initially reports the old default size (480.0, 270.0). SwiftUI equivalent struct MyView: View { var body: some View { GeometryReader { geo in VStack {} .onAppear { print(onAppear: (geo.size)) } .onChange(of: geo.size) { print(onChange: (geo.size)) } } } } Logs on launch: onAppear: (900.0, 450.0) onChange: (680.0, 658.0) Problem I need to run some setup code: Only once After the view/window has its correct restored size Withou
Replies
3
Boosts
0
Views
319
Activity
4w
CLLocationManager permission prompt never appears in Swift Playground
I am building a Swift Playgrounds App project on iPad running iPadOS 26.0.1 using the latest version of Swift Playgrounds. I need to access Core Location for a plant location logging app. What I have done: • Created an App project (not a Playground) in Swift Playgrounds • Enabled ‘Core Location When in Use’ in the app capabilities (accessed by tapping the app name) • Implemented a CLLocationManager with CLLocationManagerDelegate • Called manager.requestWhenInUseAuthorization() from .onAppear in a SwiftUI view • Called manager.startUpdatingLocation() immediately after The problem: The location permission prompt never appears when the app runs. The app does not appear in Settings → Privacy & Security → Location Services at all. There are no error messages or crashes — the app simply never requests location access. What I have ruled out: • The capability IS enabled in Swift Playgrounds app settings • The app runs without errors otherwise • This is an App project, not a classic Playground, so it shou
Replies
3
Boosts
0
Views
314
Activity
4w
Reply to SwiftUI TextField.accessibilityIdentifier is not propagated to the underlying UITextField instance.
Hello @Divyashruti, Thank you for your question. SwiftUI views do not necessarily map 1-to-1 to UIKit UIView classes, and so you should not rely on framework calls based on that assumption. Couldn't you stick to using SwiftUI modifiers, such as onChange(of:initial:_:), or use custom bindings? Hoping this helps, Richard Yeh  Developer Technical Support
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
4w
Reply to ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
Thanks for the post, and great UI in my opinion. Hope as many SwiftUI people jump into this thread but I think the issue is because you are using UIKit. I think based on the error message, the error you are seeing is a UIKit presentation issue when a UI isn’t finished so looks like .palette control group style on iOS is backed by UIKit's context menu system (UIContextMenuInteraction). https://developer.apple.com/documentation/uikit/uicontextmenuinteraction When the menu is open, a private view controller (_UIContextMenuActionsOnlyViewController) is actively being presented. I think the issue here is as UIKit strictly enforces that a UIViewController can only present one view controller at a time, but you call to present(...) fails because the underlying navigation controller is still busy presenting the context menu? Is it timing the issue? If possible, you should avoid calling UIKit's present() manually from a SwiftUI button action. Instead, update a @State or @Published property in your vi
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
4w
ToolbarItemGroup With Palette Style Cannot Present a View Controller While the Context Menu Is Visible
When I set up a toolbar item group with multiple options and set the controlGroupStyle as .palette, and when one of the options are supposed to present a view controller, I get the following error Attempt to present on (from ) which is already presenting <_UIContextMenuActionsOnlyViewController: 0x1035c19d0>. So basically the context menu we see is under the hood a view controller that is being presented. Is there a right way of fixing it, or is it maybe something that will be fixed by Apple? This is how I set up the ToolbarItemGroup on SwiftUI and the view model ultimately presents another UINavigationController that has a UIHostingController as its view controller: .toolbar { ToolbarItemGroup(placement: .topBarTrailing) { Button(ft_commons_edit.localised, systemImage: pencil) { viewModel.didTapEditAction() } Button(ft_commons_delete.localised, systemImage: trash) { viewModel.didTapDeleteAction() } } label: { Image(edit-icon) .resizable() .frame(width: 24.0, height: 24.0) } } .controlGroupSt
Replies
6
Boosts
0
Views
398
Activity
4w
SwiftUI TextField.accessibilityIdentifier is not propagated to the underlying UITextField instance.
When applying the .accessibilityIdentifier(_:) modifier to a SwiftUI TextField, the identifier is correctly added to the SwiftUI Accessibility Tree (visible in Accessibility Inspector), but it is not assigned to the accessibilityIdentifier property of the underlying UITextField instance. This causes issues for developers who monitor global notifications, such as UITextField.textDidChangeNotification. When a notification is received, the object (the UITextField) has a nil identifier, making it impossible to programmatically determine which specific text field triggered the event. Steps to Reproduce: Create a SwiftUI view containing a TextField. Apply .accessibilityIdentifier(TargetTextField) to that TextField. Set up an observer (via NotificationCenter or onReceive) for UITextField.textDidChangeNotification. Run the app and type into the text field. Inspect the accessibilityIdentifier property of the UITextField object provided by the notification. Expected Result: The UITextField.ac
Replies
1
Boosts
0
Views
258
Activity
Apr ’26
NSTextAttachment view flicker while typing in same paragraph
I using SwiftUI to wrap a NSTextView to support rich text editing. I created a subclass ImageAttachment and provided my own viewProvider and attachmentView. The insertion of the image works fine, but when I typing in the same paragraph of the image, the image will flicker during typing and pause. after typing it sometimes just display nothing, but after refresh or click other places, the image shows. The interesting part is if I typing in other paragraph, the image attachment displays well. I don't think the flicker should happen while typing in the same paragraph of the attachment, but not sure if there is a way to enforce the layout stable for the paragraph?
Topic: UI Frameworks SubTopic: AppKit
Replies
1
Boosts
0
Views
209
Activity
Apr ’26
Timing issue with updating two state variables
I have a SwiftUI view with: @State var url: URL? @State var isShowingBrowser: Bool func displayURL(url: URL) { self.url = url self.isShowingBrowser = true } var body: some View { Group { // ...... } .sheet(isPresented: $isShowingBrowser) { // browser view } } The first time I call displayBrowser, an empty browser sheet appears, with no URL. The second time, it works. It doesn't matter if I reorder the assignments in displayURL. It's like the view refreshes once with a nil URL and isShowingBrowser true, then refreshes again with the URL value. If I move both variable to an @Observable view model class then it works fine - that update seems to happen atomically. For my own project, the view model is the right way to do this, but I was confused by this behavior. What am I missing about SwiftUI?
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
211
Activity
Apr ’26
Reply to LLDB `po`/`v` commands fail in new iOS project
Thanks for the post. The latest Xcode is 26.4.1 and I just used po without any issue. On your screenshot it looks like you are on SwiftUI currently inside the View? If your fresh project is a SwiftUI app and you are placing your breakpoint directly inside the var body: some View block, LLDB frequently fails to evaluate variables. This is because the body is a ViewBuilder, and the complex generic type inference often breaks the LLDB expression evaluator. Try placing a breakpoint inside a standard function (like func test() { let x = 5 }) or an .onAppear { ... } modifier. If po works there but not in the body. It looks like you also tried v? It is your best friend in SwiftUI. po compiles code to evaluate the object. v bypasses the compiler entirely and reads the variable directly from memory. If you have a breakpoint inside your SwiftUI view, type v myVariable instead of po myVariable. It is significantly faster and works in many SwiftUI contexts where po fails. I li
Replies
Boosts
Views
Activity
Apr ’26
UITabBar (Liquid Glass) rendering breaks when UITabBarController is recreated while fully obscured by a fullscreen modal
I’m seeing a rendering issue with UITabBarController on iOS 26 (Liquid Glass), and I’d like to confirm whether others can reproduce this or have a workaround. Summary If a UITabBarController is recreated while it is fully hidden behind a fullscreen modal, the tab bar renders incorrectly after dismissal. Selected tab becomes nearly invisible Unselected tabs appear to show both selected and unselected tint colors Looks like multiple rendering states are composited incorrectly This only happens with: iOS 26 (Liquid Glass enabled) UIKit UITabBarController It does not reproduce with SwiftUI TabView. Minimal Reproduction Code This is a complete, minimal example: import UIKit // MARK: - Root class RootViewController: UIViewController { private var tabBar: UITabBarController? private var modalPresented = false override func viewDidLoad() { super.viewDidLoad() installTabBar() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) // Present once on first appear, simulating an app-laun
Replies
1
Boosts
0
Views
165
Activity
Apr ’26
Misleading error on ForEach
During refactoring of an app I made a typo which leads to a misleading error message in Xcode 26.4. I could reproduce it with a small sample code in Swift Playground. Is it a bug which should be reported? Details: I have an array containing two strings. Using a ForEach loop is fine: ForEach(appData.dataArray, id: .self) { value in Text((value.subject)t(value.room)) } but with a typo in the Text line I got an error on the ForEach line: ForEach(appData.dataArray, id: .self) { value in --> Cannot convert value of type '[MyArray]' to expected argument type 'Binding' Text((value.subject)t(value.subject.room)) } Complete sample code from Swift Playground (macOS 26): import SwiftUI class MyArray : Hashable, Equatable, Identifiable, ObservableObject, Codable { let id = UUID() @Published var subject: String @Published var room : String private enum CodingKeys : String, CodingKey { case subject case room } init(subject : String, room : String) { self.subject = subject self.room = room } func encode(to encod
Replies
2
Boosts
0
Views
1.5k
Activity
Apr ’26
SwiftUI MapKit
MapKit offers showsTraffic: Bool, which is great for displaying live traffic data on the map. However, MapPolyline sits above it, which makes it quite useless. Is this the expected behaviour?
Replies
7
Boosts
0
Views
513
Activity
Apr ’26
Reply to SwiftUI Text rendering with too small height / one line missing causing unexpected text truncation on iPhone devices
The iPhone 15 screen is big enough. Adding a ScrollView doesn't fix this. The problem isn't that there's not enough size being proposed / available to the Text. The problem is that Text internally calculates the needed number of lines wrongly and then takes on a size with a slightly too small height. I agree with your assessment that the issue is a bug on Text. I saw a similar issue in an app with larger text block, and wrapping the Text with ScrollView had the Text expand to the size a bit higher than the height it calculates, which happened to fix the issue. I can't reproduce the issue your described with my iPhone 15 Simulator + iOS 26.4 (23E244), and so can't verify if the workaround helps in your case, but good to know that it doesn't. In this situation, the only thing I can see is to switch to UITextView + UIViewRepresentable, which is not a pure SwiftUI way and is probably not your choice. Best, —— Ziqiao Chen  Worldwide Developer Relations.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’26
'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
Hi, Overview: I get the following error when trying to save / read from SwiftData It happens when I try to save color to SwiftData (code below) Error 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release Questions How can I resolve the error? I am not directly using data, I am using just Float values, swift types. Why am I getting this error? Is there a way to add a breakpoint to stop at the exact type causing the error? (Symbolic breakpoint doesn't seem to help) Or is the below code ok and not responsible for the error? Code import SwiftUI nonisolated struct ColorRepresentation: Codable { let red: Float let green: Float let blue: Float let opacity: Float init(colorResolved: Color.Resolved) { red = colorResolved.red green = colorResolved.green blue = colorResolved.blue opacity = colorResolved.opacity } func color() throws -> Color { Color( red: Double(red), green: Double(green), blue: Double(blue), opacity: Double(opacity) ) } } extension ColorRe
Replies
9
Boosts
0
Views
511
Activity
Apr ’26
.buttonStyle(.glass) background changes abruptly between 50pt and 51pt in dark mode
[Submitted as FB22612121] A SwiftUI Button using .buttonStyle(.glass) with .buttonBorderShape(.capsule) changes its background abruptly when its size goes from 50×50 to 51×51 points in dark mode. This appears to be a threshold in opacity/material rather than a smooth size-based change. The sample shows identical buttons at 40, 50, 51, and 60 points, with a clear jump between 50 and 51. Measured RGB values shift from 19,19,19 to 30,30,30. The effect also varies with the background, which points to a material/opacity change rather than a fixed fill. ENVIRONMENT iOS 26.4.1 (23E254a) iOS 26.5 (23F5059e) REPRO STEPS Create a new iOS SwiftUI project. Replace ContentView with the sample code below. Run the app or open ContentView in SwiftUI Preview (dark mode). Observe the buttons at 40×40, 50×50, 51×51, and 60×60. Compare the 50pt and 51pt buttons. ACTUAL The background changes abruptly between 50pt and 51pt. The 51pt button uses a noticeably different opacity/material, producing a visibl
Topic: UI Frameworks SubTopic: SwiftUI
Replies
1
Boosts
0
Views
222
Activity
Apr ’26