SwiftUI Weekly - Issue #207
The curated collection of links about SwiftUI. Delivered every Monday.
Reading
Container relative frames in SwiftUI
The easiest way to size a view in SwiftUI is to place it in a container and allow it to fit its content size. You can also use the frame view modifier to specify a particular concrete size. Anything related to the size of its parent needs hard work using GeometryReader, which is not the easiest way to do things correctly in SwiftUI.
Understanding SwiftUI Preferences
In SwiftUI, Preferences are a mechanism for passing data up the view hierarchy - essentially allowing child views to communicate information back to their parent views.
Drawing maps with Swift Charts
In this post we will learn how to draw maps with Swift Charts. The final result is not perfect, but I discovered a lot of interesting and unobvious cases that can be useful in the future. Swift Charts has a lot of potential.
Show a popover on iPhone in SwiftUI
n SwiftUI, we can use the popover() modifier to present a popover when a given condition is true. By default, it shows a popover on iPad in a regular horizontal size class but turns into a sheet on iPhone. Starting with iOS 16.4, we can use the presentationCompactAdaptation(_:) modifier to tell SwiftUI that we prefer popover presentation even in compact size classes. This modifier is applied to the view inside the popover's content.
Advantages of Using withAnimation
There are scenarios where withAnimation
becomes the better choice. Using withAnimation
allows animations to affect elements outside the local scope, enabling more complex and visually balanced behavior.
SwiftUI Button Image When Pressed
How do change the image a SwiftUI button shows while the user is pressing the button?