I have the following code in SwiftUI, where I use the .offset modifier to set specific positions for images in a ZStack. However, when I change to a different device format, the images move away from their intended positions. Is there a way to create constraints or improve this code to make the images maintain their positions properly across different device formats?
struct ContentView: View {
var body: some View {
ZStack {
Image("bird")
.resizable()
.aspectRatio(contentMode: .fill)
.edgesIgnoringSafeArea(.all)
Image(systemName: "camera.on.rectangle")
.offset(x: 160, y: -380)
.font(.largeTitle)
Image(systemName: "heart")
.offset(x: -160, y: 380)
.font(.largeTitle)
.foregroundColor(.red)
Image(systemName: "square.and.arrow.up.on.square")
.offset(x: -160, y: -380)
.font(.largeTitle)
}
}
}
I would appreciate any help or suggestions on how to properly position these images using constraints or any other method to ensure their position consistency across different device formats in SwiftUI. Thank you.
Thanks.