Post

Replies

Boosts

Views

Activity

Reply to Swift UI backward compatibility
Most, if not all, of the new iOS 16 features in SwiftUI will only be available from iOS 16 onwards. This is what Apple tends to do every release, so you will have to wait for your minimum deployment target to catch up with the version you need features from if you don’t want to have a lot of if-available checks. Saying this, there are some features from earlier versions of SwiftUI that, even though have been replaced, will still work on the latest versions. For example, in iOS 13-14 you would style a List like this: .listStyle(PlainListStyle()) Although in iOS 15 it was reworked to this: .listStyle(.plain) the older approach will still work. Furthermore, NavigationView has only been soft-deprecated so will continue to work as expected on iOS 16. Check the documentation to see the minimum platform deployment information for each API.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to update TabView background color
Because you are using a UIKit API in SwiftUI in an “unnatural“ way, I won’t work as expected. You’re right about it being sort of a one-time thing. Even Apple recommends staying away from this method: In general, you should not rely on implementation details of a framework (including SwiftUI) to achieve specific behaviors in your apps. In iOS 16, SwiftUI does gain a new modifier: toolbarBackground(_:for:). You can use it like this: ... .toolbarBackground(.red, for: .tabBar) I believe it only applies to the current view, so you can change the behavior at different levels of the hierarchy. See the documentation as there is a lot more you can customise now regarding bars.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to How to convert 'Binding<UIImage>' to expected argument type 'UIImage'
Doing this, like you did in the List example, works fine: ForEach($results) { $result in Image(uiImage: result.image) } Because you are passing a Binding of a collection to the data parameter of the ForEach, the content closure expects to be passed a Binding of one of the collection’s elements. This is why you can access this value with the $ prefix and then read the underlying value, in your case ImageData, without it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to macOS SwiftUI: Dropdown Menu in a MenuExtraApp not working?
Controls, like menus and pickers with the menu style, don't work when placed in a view of an NSMenuItem. I believe only simple controls and ones with button-like behaviour do. If you need the menu as it is, and because it would be classed as a complex view, I would recommend using a popover instead. Something like this should work: var statusItem: NSStatusItem? var popover: NSPopover? func applicationDidFinishLaunching(_ aNotification: Notification) {     statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)     statusItem?.button?.image = NSImage(systemSymbolName: "gearshape.circle", accessibilityDescription: "Logo")     statusItem?.button?.action = #selector(showPopover)     let hostingViewController = NSHostingController(rootView: MenuExtraView())     popover = NSPopover()     popover?.contentViewController = hostingViewController     popover?.contentSize = .init(width: 350, height: 400)     popover?.behavior = .transient } @objc func showPopover(_ button: NSButton) {     popover?.show(relativeTo: button.bounds, of: button, preferredEdge: .minY) } If you just need a standard menu for your status item instead of a view, then add an item like this: menu.addItem(withTitle: "Quit", action: #selector(NSApp.terminate), keyEquivalent: "q")
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Missing argument for parameter 'images' in call
Thank you for sharing all the code. The probable cause of your height issue is that you have wrapped the contents of your ImageCard body in a NavigationView. You don't need to do this as you are already embedding it in one in ContentView. Remove the NavigationView from ImageCard to see if this helps. If it doesn't help, which I'm sure it will, then it would be down to the fact that you are setting an explicit height of 200 to the ZStack in ImageCard. I'm not sure how much this affects things but changing this value to a smaller one might make a difference.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Swift UI backward compatibility
Most, if not all, of the new iOS 16 features in SwiftUI will only be available from iOS 16 onwards. This is what Apple tends to do every release, so you will have to wait for your minimum deployment target to catch up with the version you need features from if you don’t want to have a lot of if-available checks. Saying this, there are some features from earlier versions of SwiftUI that, even though have been replaced, will still work on the latest versions. For example, in iOS 13-14 you would style a List like this: .listStyle(PlainListStyle()) Although in iOS 15 it was reworked to this: .listStyle(.plain) the older approach will still work. Furthermore, NavigationView has only been soft-deprecated so will continue to work as expected on iOS 16. Check the documentation to see the minimum platform deployment information for each API.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to SwiftUI List Separator within NavigationView Problem
The problem was that List was defaulting to a .sidebar list style which caused the separators to be inset as if there was a symbol image there. This could be fixed by manually changing to another list style. This has since been resolved in iOS 16, and the ability to modify separator insets has been added.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to SwiftUI: Bottom sheet from the iPhone "find my" and "maps" app
This is currently a limitation with the new API. I have already filed feedback and I suggest you do too.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Changing the images and tint of the icons provided by NavigationSplitView
Setting the values in the AccentColor colour set in the asset catalog to your desired tint colour should work. I don’t know if using the tint(_:) modifier works but you could try that too.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to SwiftUI TabView with page style doesn't present dots on watchOS
It might be a bug in watchOS 9. If it’s not, then you can manually control the indicators by adding this parameter to the tab view style: .tabViewStyle(.page(indexDisplayMode: .always))
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Problems with NavigationView() and NavigationLink
Can you show us some code that will help to explain why this is happening? It seems like you have multiple NavigationViews each with NavigationLinks that cause this stacked appearance.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to update TabView background color
Because you are using a UIKit API in SwiftUI in an “unnatural“ way, I won’t work as expected. You’re right about it being sort of a one-time thing. Even Apple recommends staying away from this method: In general, you should not rely on implementation details of a framework (including SwiftUI) to achieve specific behaviors in your apps. In iOS 16, SwiftUI does gain a new modifier: toolbarBackground(_:for:). You can use it like this: ... .toolbarBackground(.red, for: .tabBar) I believe it only applies to the current view, so you can change the behavior at different levels of the hierarchy. See the documentation as there is a lot more you can customise now regarding bars.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to How to convert 'Binding<UIImage>' to expected argument type 'UIImage'
Doing this, like you did in the List example, works fine: ForEach($results) { $result in Image(uiImage: result.image) } Because you are passing a Binding of a collection to the data parameter of the ForEach, the content closure expects to be passed a Binding of one of the collection’s elements. This is why you can access this value with the $ prefix and then read the underlying value, in your case ImageData, without it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to how to assign to Binding<String>
You can assign a value directly to the variable, like this: url = tempUrl
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to The primary action of Menu cannot triggered
File feedback as this seems to be an issue.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to macOS SwiftUI: Dropdown Menu in a MenuExtraApp not working?
I forgot to add this, but when you do start to target macOS Ventura, menus and pickers will work properly in a MenuBarExtra with the .window style.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to NavigationStack doesn't refresh its body when a state value changes from `nil`
From the iOS & iPadOS 16 Beta 3 Release Notes: Conditional views in columns of NavigationSplitView fail to update on some state changes. (91311311) Workaround: Wrap the contents of the column in a ZStack. It mentions NavigationSplitView, but it must apply to NavigationStack as wrapping the if statement in your example in a ZStack updates the view.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to macOS SwiftUI: Dropdown Menu in a MenuExtraApp not working?
Controls, like menus and pickers with the menu style, don't work when placed in a view of an NSMenuItem. I believe only simple controls and ones with button-like behaviour do. If you need the menu as it is, and because it would be classed as a complex view, I would recommend using a popover instead. Something like this should work: var statusItem: NSStatusItem? var popover: NSPopover? func applicationDidFinishLaunching(_ aNotification: Notification) {     statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)     statusItem?.button?.image = NSImage(systemSymbolName: "gearshape.circle", accessibilityDescription: "Logo")     statusItem?.button?.action = #selector(showPopover)     let hostingViewController = NSHostingController(rootView: MenuExtraView())     popover = NSPopover()     popover?.contentViewController = hostingViewController     popover?.contentSize = .init(width: 350, height: 400)     popover?.behavior = .transient } @objc func showPopover(_ button: NSButton) {     popover?.show(relativeTo: button.bounds, of: button, preferredEdge: .minY) } If you just need a standard menu for your status item instead of a view, then add an item like this: menu.addItem(withTitle: "Quit", action: #selector(NSApp.terminate), keyEquivalent: "q")
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Searchable FocusState
I would file feedback for this as I can't find a solution, yet.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22
Reply to Missing argument for parameter 'images' in call
Thank you for sharing all the code. The probable cause of your height issue is that you have wrapped the contents of your ImageCard body in a NavigationView. You don't need to do this as you are already embedding it in one in ContentView. Remove the NavigationView from ImageCard to see if this helps. If it doesn't help, which I'm sure it will, then it would be down to the fact that you are setting an explicit height of 200 to the ZStack in ImageCard. I'm not sure how much this affects things but changing this value to a smaller one might make a difference.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’22