March 2, 2024

SwiftUI Useful Modifiers

.resizeable() – Modifier that makes the view resizable. e.g.

.edgesIgnoringSafeArea(.all) – Modifier that causes the view to cross the safe area boundaries.

Safe area options:

@State – This tells SwiftUI to manage the storage of the property. When the property value changes, the view is re-rendered to use the latest value. To pass a state property to another view in the view hierarchy, use the variable name with the $ prefix operator. (

.clipShape(shape) – modifies the view to the specified shape. Default is circle. Following example clips an image to give it a circular effect:

.overlay(view) – Is a modifier that overlays a view on top. In the following example, the .overlay() modifier is used to overlay a stroked circle on top of a clipped image. This gives the circular image a grey outline circle: