It is possible to set a background image behind a FORM in swiftUI?

Hi everyone, i'm building an app and I would like to add a background image behind a Form.
It is possible in swiftUI?
Thanks!!
Answered by BabyJ in 657426022
You can add this to your view struct:
Code Block Swift
.onAppear {
UITableView.appearance().backgroundView = UIImageView(image: UIImage(named: "imageName"))
}
It uses a bit of UIKit to change the background view behind the form, not including the rows.
The image being passed in to the UIImageView needs to be a UIImage. Take a look at the documentation if you need more information on how to configure one.
ZStack{
      Image("img")
      Form{
    Text("Hello, world!")
    Text("Hello, world!")
    Text("Hello, world!")

      }.padding()
  }
It doesn't work, I had already tried this.




Accepted Answer
You can add this to your view struct:
Code Block Swift
.onAppear {
UITableView.appearance().backgroundView = UIImageView(image: UIImage(named: "imageName"))
}
It uses a bit of UIKit to change the background view behind the form, not including the rows.
The image being passed in to the UIImageView needs to be a UIImage. Take a look at the documentation if you need more information on how to configure one.
It is possible to set a background image behind a FORM in swiftUI?
 
 
Q