I want to use HSTack to get the width value to the image on UISscreen.

Asked 1 years ago, Updated 1 years ago, 272 views

I would like to use HSTack to determine the width value on the UISscreen up to Image("test") and get the value. What should I do?

struct ContentView:View {
    varbody:someView {
        HSTack {
            Text ("Apple")
                .font (.largeTitle)
                .frame (width: 200)
                .background (Color.yellow)
             Image ("test")
                .resizable()
                .frame (width:300, height:150)
        }
    }
}

Enter a description of the image here

swift ios swiftui

2022-09-30 22:04

1 Answers

It's solved.
.background() has a value similar to that obtained by GeometryReader.


2022-09-30 22:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.