swiftui

SwiftUI: Updating an array item does not update the child UI immediately

╄→尐↘猪︶ㄣ 提交于 2021-01-01 04:21:49
问题 I have an array of items (numbers) to be presented to the user using NavigationView, List and a leaf page. When I update an item (numbers[index] = ...) on a leaf page, it updates the list correctly (which I see when I go back to the list), but not the leaf page itself immediately. I see the change if I go back to the list and re-open the same leaf page. I would like to understand why it does not update the UI immediately, and how to fix it. Here is the simplified code to re-produce this

SwiftUI macos NSWindow instance

血红的双手。 提交于 2021-01-01 04:17:45
问题 Using xcode 12.3 and swift 5.3 with the SwiftUI App Life cycle to build a macOS application, what is the best way to access and change the appearance and behaviour of the NSWindow ? Edit: What I'm really after is the NSWindow instance. I've added an AppDelegate , but as I understand it the NSWindow is likely to be nil , so unavailable for modification, and simply creating one here similar to the AppKit App Delegate Life cycle method results in two windows appearing at launch. One solution

What is the difference between navigationBarTitle and navigationTitle modifiers in SwiftUI 2.0?

。_饼干妹妹 提交于 2020-12-31 15:00:41
问题 Learning all the new SwiftUI 2.0 changes but came across .navigationTitle which seems to work almost exactly like .navigationBarTitle . I looked at the WWDC 2020 videos and found one video where it was mentioned as being used to distinguish tab titles in MacOS? But not sure if it I should use it now instead of .navigationBarTitle in iOS? Also the Apple documentation is not clear about the differences between the two.. So my question is, what are the exact differences and how would you use

What is the difference between navigationBarTitle and navigationTitle modifiers in SwiftUI 2.0?

安稳与你 提交于 2020-12-31 14:56:27
问题 Learning all the new SwiftUI 2.0 changes but came across .navigationTitle which seems to work almost exactly like .navigationBarTitle . I looked at the WWDC 2020 videos and found one video where it was mentioned as being used to distinguish tab titles in MacOS? But not sure if it I should use it now instead of .navigationBarTitle in iOS? Also the Apple documentation is not clear about the differences between the two.. So my question is, what are the exact differences and how would you use

How to display a fullstack modal with SwiftUI?

无人久伴 提交于 2020-12-31 06:50:07
问题 I have a navbar up to and a tab bar at the bottom for most of the navigation in my app. I'm trying to display a fullscreen view, effectively removing all navigation, when clicking a button. Other questions on SO address this case when there is no navbar or no tab bar, so they don't really answer my use case. Here what I have tried: Hide the navbar & tab bar on click: doesn't work for the tab bar. The top navigation becomes buggy if I try to go back to another view when dismissing the full

How to display a fullstack modal with SwiftUI?

戏子无情 提交于 2020-12-31 06:49:41
问题 I have a navbar up to and a tab bar at the bottom for most of the navigation in my app. I'm trying to display a fullscreen view, effectively removing all navigation, when clicking a button. Other questions on SO address this case when there is no navbar or no tab bar, so they don't really answer my use case. Here what I have tried: Hide the navbar & tab bar on click: doesn't work for the tab bar. The top navigation becomes buggy if I try to go back to another view when dismissing the full

SwiftUI - How can I blur the default background color of a view?

妖精的绣舞 提交于 2020-12-31 05:43:54
问题 no code to show here, but I would like to know how it may be possible to do this. I have tried to use .blur(radius: (20) on a view, but it tends to blur the entire view. Including the text, and anything else in the view. The default background color is fine and I don't want/need to change it (in order to keep the app compatible with light/dark mode). I want to make the view's background slightly blurred/opaque, but I want the text and buttons in the view to still remain full and normal. Is

SwiftUI - How can I blur the default background color of a view?

拥有回忆 提交于 2020-12-31 05:42:11
问题 no code to show here, but I would like to know how it may be possible to do this. I have tried to use .blur(radius: (20) on a view, but it tends to blur the entire view. Including the text, and anything else in the view. The default background color is fine and I don't want/need to change it (in order to keep the app compatible with light/dark mode). I want to make the view's background slightly blurred/opaque, but I want the text and buttons in the view to still remain full and normal. Is

SwiftUI Map Display Annotations

随声附和 提交于 2020-12-31 05:24:42
问题 I decided to switch from wrapping MKMapView into a UIViewRepresentable to the new Map() in SwiftUI. I was able to display correctly a MKMapRect into the Map() but I am unable to display two MKPointAnnotation there. Also my route between these annotation is not showing It is requiring me to provide an RandomAccessCollection and a (Identifiable) -> MapAnnotationProtocol> but I do not know what to put there. Any idea what should I put in (Identifiable) -> MapAnnotationProtocol ? import SwiftUI

SwiftUI Map Display Annotations

梦想的初衷 提交于 2020-12-31 05:24:41
问题 I decided to switch from wrapping MKMapView into a UIViewRepresentable to the new Map() in SwiftUI. I was able to display correctly a MKMapRect into the Map() but I am unable to display two MKPointAnnotation there. Also my route between these annotation is not showing It is requiring me to provide an RandomAccessCollection and a (Identifiable) -> MapAnnotationProtocol> but I do not know what to put there. Any idea what should I put in (Identifiable) -> MapAnnotationProtocol ? import SwiftUI