Search results for

“swiftui”

17,233 results found

Post

Replies

Boosts

Views

Activity

SwiftUI Link view corrupts destination URLs when using a leading-zero padded IPv4 address.
There appears to be a bug in Link with IPv4 addresses with padding in the second octet, on macOS and iOS both. struct LinkViewBug: View { let works = URL(string: http://172.16.1.1)! let alsoWorks = URL(string: http://172.16.001.001)! let doesntWork = URL(string: http://172.016.001.001)! let alsoDoesntWork = URL(string: http://172.016.1.1)! var body: some View { // destination -> http://172.16.1.1 Link(works.formatted(), destination: works) Link(alsoWorks.formatted(), destination: alsoWorks) // destination -> http://172.14.1.1 ? Link(doesntWork.formatted(), destination: doesntWork) Link(alsoDoesntWork.formatted(), destination: alsoDoesntWork) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
0
0
87
Feb ’26
In SwiftUI for macOS, is there an equivalent to NSControl.BorderShape?
In macOS 26, there is a new property on NSControl called .borderShape. The WWDC 2025-310 video says it can be used to Override preferred shape of control to suit your design. and that it's available on NSButton, NSPopUpButton and NSSegmentedControl. Is there an equivalent to that property for SwiftUI? For example, given the following SwiftUI code: Button(Eject) { } .borderShape(...) <-- ? How can I apply a .borderShape that would match those on controls created in AppKit? I'm aware that SwiftUI offers a plethora of ways to custom design a button such that it can have rounded corners, but I'm interested in this particular property so that SwiftUI buttons and AppKit buttons in the same app have the same look-and-feel.
1
0
125
Feb ’26
Reply to Do SwiftUI Segmented Controls on macOS 26 support the icon and title label style?
Hello @kennyc, Displaying the title and icon within a segmented control is currently not supported for SwiftUI's .segmentedPickerStyle. If you'd like us to consider adding the necessary functionality for this, please file an enhancement request using Feedback Assistant and reply with FB number here once complete. Consider also, the Human Interface Guidelines recommends using either text or an image in a single segmented control, not a mix. You can review the Segmented controls section of the guidelines for more best practices.  Travis Trotto - DTS Engineer
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’26
Reply to Button in ToolbarItem is not completely tapable on iOS 26
Hi Albert, I have created a reproducible example for you to try. import SwiftUI struct ContentView: View { @State private var isBookmarked = false var body: some View { NavigationStack { VStack { Text(isBookmarked ? Bookmarked : Not bookmarked) } .padding() .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button(action: toggleBookmark) { Image(systemName: isBookmarked ? bookmark.fill : bookmark) } } } } } private func toggleBookmark() { isBookmarked.toggle() } } #Preview { ContentView() } You can see in this simple example without any additional modifiers, that whole circular area is not tappable. Also using Circle() .foregroundColor(.clear) .frame(width: 54, height: 54) still leaves some un-tappable area in item.
Topic: UI Frameworks SubTopic: SwiftUI
Feb ’26
Reply to URL Filter Network Extension
[quote='877011022, Pushpak-Ambadkar123, /thread/815498?answerId=877011022#877011022, /profile/Pushpak-Ambadkar123'] will it work with WebKit as well … ? [/quote] Hmmmm, that depends on what you mean by “WebKit”. If you’re talking about WKWebView (WebView in SwiftUI) then I expect, like Safari, it’d get filter support because it loads web content using URLSession. If you’re talking about the WebKit open source project, that’s not something I support and thus I’ve not looked at it. [quote='877011022, Pushpak-Ambadkar123, /thread/815498?answerId=877011022#877011022, /profile/Pushpak-Ambadkar123'] I am trying to implement a solution that would block urls from the block list on the browsers installed on iOS device. [/quote] Can you clarify what you mean by that? But, just so we’re on the same page about Network Extension’s capabilities, it supports two scenarios: Implementing a URL filter — This allows you to block pages loaded by URLSession and anything layered on top of it, including WebKit’s web views
Feb ’26
Performance degradation and redraw loops when syncing SwiftUI Charts with custom AxisMarks
I am reporting a reproducible performance issue in iOS 18.6 where synchronizing the scroll position of two Chart views via chartScrollPosition(id:) causes a complete redraw loop when custom AxisMarks are used. This occurs even when the axis marks are technically hidden, leading to significant frame drops and stuttering on modern hardware like the iPhone 15. Environment Device: iPhone 15 OS: iOS 18.6 (22G86) Frameworks: SwiftUI, Swift Charts, Observation The Issue When using a shared @Observable state to sync two charts, the scrolling is fluid only if the axes are at their default settings. As soon as a custom AxisMarks block is added to either chart, the following behavior is observed: Diffing Failure: The framework appears unable to maintain the identity of the axis components during the scroll update. Redraw Loop: Instead of an incremental scroll translation, the diffing algorithm triggers a full reload/re-render of both charts on every scroll offset change. Impact: CPU spikes to 100% and the UI be
1
0
161
Feb ’26
Transparency in Sheet differs in SwiftUI and UIKit+UIHostingContrller
My app is a UIKit app with a lot of SwiftUI mixed in. A common scenario is that a UIViewController presents a sheet with a SwiftUI view wrapped in a UIHostingController. When I present the exact same SwiftUI View it looks different in a SwiftUI sheet compared to when it's wrapped in a UIHostingController and presented from a view controller. I'm using a hacky workaround in which I loop through all subviews of the hosting controller in viewWillLayoutSubviews and look for a NavigationStackHostingController to manually set the background color, but it feels like it could brake easily. Has anyone found a better way to fix this? Feedback: FB22028838
0
0
168
Feb ’26
Do SwiftUI Segmented Controls on macOS 26 support the icon and title label style?
On macOS 26.3, Xcode 26.3, why does a labelStyle of titleAndIcon not show both the title and the icon of a label? The label styles iconOnly and titleOnly behave as expected. Picker(Label Demo, selection: $selectedItem) { Label { Text(File) } icon: { Image(systemName: doc) } Label { Text(Folder) } icon: { Image(systemName: folder) } } .labelStyle(.titleAndIcon) .pickerStyle(.segmented) Note that there is no icon shown. Placing the .labelStyle modifier in different places has no effect. The icon is correctly shown when the labelStyle is set to .iconOnly. An NSSegmentedControl created with AppKit and presented in an NSViewRepresentable does correctly show titles and icons if configured appropriately. Tested on: macOS 26.3 (25D125) Xcode 26.3 (17C519) A brand new SwiftUI macOS App project.
2
0
147
Feb ’26
Reply to How to delete a row from a table
Welcome to the forum. array is the data source. So if you remove an item in array, the table should update automatically. Here a very basic example struct Customer: Identifiable { let id = UUID() let name: String let email: String } struct ContentView: View { @State var customers = [Customer(name: John Smith, email: john.smith @ example.com), Customer(name: Jane Doe, email: jane.doe @ example.com), Customer(name: Bob Johnson, email: bob.johnson @ example.com)] var body: some View { Table(customers) { TableColumn(name, value: .name) TableColumn(email, value: .email) } Button(Remove Jane Doe) { customers.removeAll(where: { $0.name == Jane Doe} ) } } } See details here: https://developer.apple.com/documentation/swiftui/table PS: you have a typo with the double backslash: .ticker If that answers your question, don't forget to close the thread by marking the answer as correct.
Topic: UI Frameworks SubTopic: SwiftUI
Feb ’26
Mac App Store app triggers "cannot verify free of malware" alert when opening as default app
My app Mocawave is a music player distributed through the Mac App Store. It declares specific audio document types (public.mp3, com.microsoft.waveform-audio, public.mpeg-4-audio, public.aac-audio) in its CFBundleDocumentTypes with a Viewer role. When a user sets Mocawave as the default app for audio files and double-clicks an MP3 downloaded from the internet (which has the com.apple.quarantine extended attribute), macOS displays the alert: Apple could not verify [filename] is free of malware that may harm your Mac or compromise your privacy. This does not happen when: Opening the same file via NSOpenPanel from within the app Opening the same file with Apple's Music.app or QuickTime Player The app is: Distributed through the Mac App Store Sandboxed (com.apple.security.app-sandbox) Uses com.apple.security.files.user-selected.read-write entitlement The file being opened is a regular audio file (MP3), not an executable. Since the app is sandboxed and distributed through the App Store, I expected it to have suffic
2
0
249
Feb ’26
Does Liquid Glass ignore regular hit testing in SwiftUI?
I’ve encountered an aspect of the Liquid Glass effect in SwiftUI that seems a bit odd: the Liquid Glass interaction appears to ignore regular hit-testing behavior. The following sample shows a button with hit testing disabled: @main struct LiquidGlassHitTestDemo: App { var body: some Scene { WindowGroup { Button(Liquid) { fatalError(Never called.) } .buttonStyle(.glassProminent) .allowsHitTesting(false) } } } As expected, the button’s action is never called. However, the interactive glass effect still responds to touch events: What’s even more surprising is that the UIKit equivalent behaves differently: final class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let button = UIButton( configuration: .prominentGlass(), primaryAction: UIAction( title: Liquid, handler: { action in print(Never called.) } ) ) view.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ button.centerXAnchor.constraint(equalTo: view.cente
0
0
123
Feb ’26
Reply to Fix text in accessory view
On second thought, considering that this works differently in UIKit then SwiftUI, I think its best we file a bug report and get to the bottom of this. Please file a bug report here and reply with the feedback number once complete, I'll make sure it winds up with the correct team. Thank you,  Travis Trotto - DTS Engineer
Topic: UI Frameworks SubTopic: SwiftUI
Feb ’26
Reply to Button in ToolbarItem is not completely tapable on iOS 26
Thank you for sharing the post and the partial code. I suggest posting the code starting from the Toolbar instead of providing only a ToolbarItem. Hope other SwiftUI gurus here can jump into this thread as my SwiftUI skills are not as good as others for sure!! Looking at your item it seems like you are setting the frame to 20x20? I think by default in SwiftUI only registers taps within the bounds of its content. Taps on the surrounding padding or button area are ignored. To ensure taps anywhere within the trigger the action, we can use a to expand the tappable area, see your frame? The modifier ensures that taps anywhere within the defined shape are recognized. // Removing the Toolbar too :-) ToolbarItem(placement: .navigationBarTrailing) { // guessing on toggleBookmark :-) Button(action: toggleBookmark) { ZStack { Circle() .foregroundColor(.clear) .frame(width: 54, height: 54) // Adjust size as needed Image(systemName: isBookmarked ? bookmark.fill : bookmark) .resizable() .aspectRa
Topic: UI Frameworks SubTopic: SwiftUI
Feb ’26
SwiftUI Link view corrupts destination URLs when using a leading-zero padded IPv4 address.
There appears to be a bug in Link with IPv4 addresses with padding in the second octet, on macOS and iOS both. struct LinkViewBug: View { let works = URL(string: http://172.16.1.1)! let alsoWorks = URL(string: http://172.16.001.001)! let doesntWork = URL(string: http://172.016.001.001)! let alsoDoesntWork = URL(string: http://172.016.1.1)! var body: some View { // destination -> http://172.16.1.1 Link(works.formatted(), destination: works) Link(alsoWorks.formatted(), destination: alsoWorks) // destination -> http://172.14.1.1 ? Link(doesntWork.formatted(), destination: doesntWork) Link(alsoDoesntWork.formatted(), destination: alsoDoesntWork) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
0
Boosts
0
Views
87
Activity
Feb ’26
In SwiftUI for macOS, is there an equivalent to NSControl.BorderShape?
In macOS 26, there is a new property on NSControl called .borderShape. The WWDC 2025-310 video says it can be used to Override preferred shape of control to suit your design. and that it's available on NSButton, NSPopUpButton and NSSegmentedControl. Is there an equivalent to that property for SwiftUI? For example, given the following SwiftUI code: Button(Eject) { } .borderShape(...) <-- ? How can I apply a .borderShape that would match those on controls created in AppKit? I'm aware that SwiftUI offers a plethora of ways to custom design a button such that it can have rounded corners, but I'm interested in this particular property so that SwiftUI buttons and AppKit buttons in the same app have the same look-and-feel.
Replies
1
Boosts
0
Views
125
Activity
Feb ’26
Reply to Do SwiftUI Segmented Controls on macOS 26 support the icon and title label style?
Hello @kennyc, Displaying the title and icon within a segmented control is currently not supported for SwiftUI's .segmentedPickerStyle. If you'd like us to consider adding the necessary functionality for this, please file an enhancement request using Feedback Assistant and reply with FB number here once complete. Consider also, the Human Interface Guidelines recommends using either text or an image in a single segmented control, not a mix. You can review the Segmented controls section of the guidelines for more best practices.  Travis Trotto - DTS Engineer
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26
Reply to Button in ToolbarItem is not completely tapable on iOS 26
Hi Albert, I have created a reproducible example for you to try. import SwiftUI struct ContentView: View { @State private var isBookmarked = false var body: some View { NavigationStack { VStack { Text(isBookmarked ? Bookmarked : Not bookmarked) } .padding() .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button(action: toggleBookmark) { Image(systemName: isBookmarked ? bookmark.fill : bookmark) } } } } } private func toggleBookmark() { isBookmarked.toggle() } } #Preview { ContentView() } You can see in this simple example without any additional modifiers, that whole circular area is not tappable. Also using Circle() .foregroundColor(.clear) .frame(width: 54, height: 54) still leaves some un-tappable area in item.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Feb ’26
Reply to URL Filter Network Extension
[quote='877011022, Pushpak-Ambadkar123, /thread/815498?answerId=877011022#877011022, /profile/Pushpak-Ambadkar123'] will it work with WebKit as well … ? [/quote] Hmmmm, that depends on what you mean by “WebKit”. If you’re talking about WKWebView (WebView in SwiftUI) then I expect, like Safari, it’d get filter support because it loads web content using URLSession. If you’re talking about the WebKit open source project, that’s not something I support and thus I’ve not looked at it. [quote='877011022, Pushpak-Ambadkar123, /thread/815498?answerId=877011022#877011022, /profile/Pushpak-Ambadkar123'] I am trying to implement a solution that would block urls from the block list on the browsers installed on iOS device. [/quote] Can you clarify what you mean by that? But, just so we’re on the same page about Network Extension’s capabilities, it supports two scenarios: Implementing a URL filter — This allows you to block pages loaded by URLSession and anything layered on top of it, including WebKit’s web views
Replies
Boosts
Views
Activity
Feb ’26
Performance degradation and redraw loops when syncing SwiftUI Charts with custom AxisMarks
I am reporting a reproducible performance issue in iOS 18.6 where synchronizing the scroll position of two Chart views via chartScrollPosition(id:) causes a complete redraw loop when custom AxisMarks are used. This occurs even when the axis marks are technically hidden, leading to significant frame drops and stuttering on modern hardware like the iPhone 15. Environment Device: iPhone 15 OS: iOS 18.6 (22G86) Frameworks: SwiftUI, Swift Charts, Observation The Issue When using a shared @Observable state to sync two charts, the scrolling is fluid only if the axes are at their default settings. As soon as a custom AxisMarks block is added to either chart, the following behavior is observed: Diffing Failure: The framework appears unable to maintain the identity of the axis components during the scroll update. Redraw Loop: Instead of an incremental scroll translation, the diffing algorithm triggers a full reload/re-render of both charts on every scroll offset change. Impact: CPU spikes to 100% and the UI be
Replies
1
Boosts
0
Views
161
Activity
Feb ’26
Transparency in Sheet differs in SwiftUI and UIKit+UIHostingContrller
My app is a UIKit app with a lot of SwiftUI mixed in. A common scenario is that a UIViewController presents a sheet with a SwiftUI view wrapped in a UIHostingController. When I present the exact same SwiftUI View it looks different in a SwiftUI sheet compared to when it's wrapped in a UIHostingController and presented from a view controller. I'm using a hacky workaround in which I loop through all subviews of the hosting controller in viewWillLayoutSubviews and look for a NavigationStackHostingController to manually set the background color, but it feels like it could brake easily. Has anyone found a better way to fix this? Feedback: FB22028838
Replies
0
Boosts
0
Views
168
Activity
Feb ’26
Do SwiftUI Segmented Controls on macOS 26 support the icon and title label style?
On macOS 26.3, Xcode 26.3, why does a labelStyle of titleAndIcon not show both the title and the icon of a label? The label styles iconOnly and titleOnly behave as expected. Picker(Label Demo, selection: $selectedItem) { Label { Text(File) } icon: { Image(systemName: doc) } Label { Text(Folder) } icon: { Image(systemName: folder) } } .labelStyle(.titleAndIcon) .pickerStyle(.segmented) Note that there is no icon shown. Placing the .labelStyle modifier in different places has no effect. The icon is correctly shown when the labelStyle is set to .iconOnly. An NSSegmentedControl created with AppKit and presented in an NSViewRepresentable does correctly show titles and icons if configured appropriately. Tested on: macOS 26.3 (25D125) Xcode 26.3 (17C519) A brand new SwiftUI macOS App project.
Replies
2
Boosts
0
Views
147
Activity
Feb ’26
Reply to How to delete a row from a table
Welcome to the forum. array is the data source. So if you remove an item in array, the table should update automatically. Here a very basic example struct Customer: Identifiable { let id = UUID() let name: String let email: String } struct ContentView: View { @State var customers = [Customer(name: John Smith, email: john.smith @ example.com), Customer(name: Jane Doe, email: jane.doe @ example.com), Customer(name: Bob Johnson, email: bob.johnson @ example.com)] var body: some View { Table(customers) { TableColumn(name, value: .name) TableColumn(email, value: .email) } Button(Remove Jane Doe) { customers.removeAll(where: { $0.name == Jane Doe} ) } } } See details here: https://developer.apple.com/documentation/swiftui/table PS: you have a typo with the double backslash: .ticker If that answers your question, don't forget to close the thread by marking the answer as correct.
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Feb ’26
Mac App Store app triggers "cannot verify free of malware" alert when opening as default app
My app Mocawave is a music player distributed through the Mac App Store. It declares specific audio document types (public.mp3, com.microsoft.waveform-audio, public.mpeg-4-audio, public.aac-audio) in its CFBundleDocumentTypes with a Viewer role. When a user sets Mocawave as the default app for audio files and double-clicks an MP3 downloaded from the internet (which has the com.apple.quarantine extended attribute), macOS displays the alert: Apple could not verify [filename] is free of malware that may harm your Mac or compromise your privacy. This does not happen when: Opening the same file via NSOpenPanel from within the app Opening the same file with Apple's Music.app or QuickTime Player The app is: Distributed through the Mac App Store Sandboxed (com.apple.security.app-sandbox) Uses com.apple.security.files.user-selected.read-write entitlement The file being opened is a regular audio file (MP3), not an executable. Since the app is sandboxed and distributed through the App Store, I expected it to have suffic
Replies
2
Boosts
0
Views
249
Activity
Feb ’26
Does Liquid Glass ignore regular hit testing in SwiftUI?
I’ve encountered an aspect of the Liquid Glass effect in SwiftUI that seems a bit odd: the Liquid Glass interaction appears to ignore regular hit-testing behavior. The following sample shows a button with hit testing disabled: @main struct LiquidGlassHitTestDemo: App { var body: some Scene { WindowGroup { Button(Liquid) { fatalError(Never called.) } .buttonStyle(.glassProminent) .allowsHitTesting(false) } } } As expected, the button’s action is never called. However, the interactive glass effect still responds to touch events: What’s even more surprising is that the UIKit equivalent behaves differently: final class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let button = UIButton( configuration: .prominentGlass(), primaryAction: UIAction( title: Liquid, handler: { action in print(Never called.) } ) ) view.addSubview(button) button.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([ button.centerXAnchor.constraint(equalTo: view.cente
Replies
0
Boosts
0
Views
123
Activity
Feb ’26
Reply to Fix text in accessory view
On second thought, considering that this works differently in UIKit then SwiftUI, I think its best we file a bug report and get to the bottom of this. Please file a bug report here and reply with the feedback number once complete, I'll make sure it winds up with the correct team. Thank you,  Travis Trotto - DTS Engineer
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Feb ’26
Reply to How create Wishlist toolbar layout? (SwiftUI foundations: Build great apps with SwiftUI)
Hello commin, Thanks for your question and interest in the SwiftUI Foundations event! Can you please share a code snippet of your attempt to replicate this layout? Best regards, Richard Yeh  Developer Technical Support
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’26
How create Wishlist toolbar layout? (SwiftUI foundations: Build great apps with SwiftUI)
in SwiftUI foundations: Build great apps with SwiftUI Toolbar have navigationTitle with align leading. I try to create same layout. but it fail How was it possible?
Replies
4
Boosts
0
Views
218
Activity
Feb ’26
Reply to Button in ToolbarItem is not completely tapable on iOS 26
Thank you for sharing the post and the partial code. I suggest posting the code starting from the Toolbar instead of providing only a ToolbarItem. Hope other SwiftUI gurus here can jump into this thread as my SwiftUI skills are not as good as others for sure!! Looking at your item it seems like you are setting the frame to 20x20? I think by default in SwiftUI only registers taps within the bounds of its content. Taps on the surrounding padding or button area are ignored. To ensure taps anywhere within the trigger the action, we can use a to expand the tappable area, see your frame? The modifier ensures that taps anywhere within the defined shape are recognized. // Removing the Toolbar too :-) ToolbarItem(placement: .navigationBarTrailing) { // guessing on toggleBookmark :-) Button(action: toggleBookmark) { ZStack { Circle() .foregroundColor(.clear) .frame(width: 54, height: 54) // Adjust size as needed Image(systemName: isBookmarked ? bookmark.fill : bookmark) .resizable() .aspectRa
Topic: UI Frameworks SubTopic: SwiftUI
Replies
Boosts
Views
Activity
Feb ’26