Good morning, everyone,
I am learning SwiftUI, and I watched the whole course on Raywenderlich's website ("Your First Ios and SwiftUI app").
In it, we learn to create a struct and method that allows us to modify a view.
While trying to create a small application, thanks to this answer, I know that I have to create a ZStack to be able to modify the background.
However, when I try to create a struct and method to modify my ZStack, many errors are reported.
Here's my code :
public struct BackGroundColor : ModifiedContent {
public body (content : Content) -> some View {
return content
Color.init(red: 222/255, green: 196/255, blue: 125/255)
.edgesIgnoringSafeArea(.all)
}
}
// When I call the struc in my body
struct ContentView: View {
var body: some View {
ZStack {
.BackGroundColor()
// some code
}
}
}
In addition, I would like this struct to be public so that it can be used anywhere in my other files.
Thank you for your answers