SwiftUI: How do I tell when my device orientation changes

Sorry to repeat this, but the new style forum won't allow me access to the original version of this question, and the answers.

I have been searching the internet for 3 or 4 days now to find only complex solutions that I cannot get working.

All I want to do is determine when the device orientation changes so that I can update the background Image. This is what I have so far:

Import SwiftUI

struct Main_Menu_iPhone: View {
    @State private var bloodGlucose: Float = 0.0
    var body: some View {
        ZStack {
            Image("iPhone Background Portrait 828 x 1792 ")
                .resizable()
                .aspectRatio(contentMode: .fill)

           VStack {
               HStack  {
                   Label("Blood Glucose", systemImage: "drop.fill")
                   TextField("Blood Glucose : ", value: $bloodGlucose, format: .number)
                       .onSubmit() {
                           print("Your Blood Gluse is : \(bloodGlucose)")
                       }
                       .background(.white)
                       .frame(alignment: .topTrailing)
                        Spacer()
               }
                     Spacer()
           }.padding(.top, 250)
        }
        
    }
    
}
Answered by Forums Product Manager in 788498022
Sorry to repeat this, but the new style forum won't allow me access to the original version of this question, and the answers.

Hi @jamesm46,

Welcome to the new Developer Forums! You can find all your posts and activity by visiting the "My Activity" tab located on the homepage of Developer Forums.

You can also access this via your profile page.

Sorry to repeat this, but the new style forum won't allow me access to the original version of this question, and the answers.

Hi @jamesm46,

Welcome to the new Developer Forums! You can find all your posts and activity by visiting the "My Activity" tab located on the homepage of Developer Forums.

You can also access this via your profile page.

SwiftUI: How do I tell when my device orientation changes
 
 
Q