Just in case someone is still working through this issue, or one close to it.
My issue was where both Views where SwiftUI Views (one an Image and the other a user interactive Form full of Sections and widgets). I wanted the image to set up a look and feel for the form being filled in.
The answer is to go around SwiftUI by adjusting your thinking and make the Image fully opaque and the Form see through at about 80% - or to taste. Then mark the Image non-interactive (.allowsHitTesting(false)) and the Form interactive (.allowsHitTesting(true)).
My implementation used View Modifiers:
// Original Form
Form { (various Widgets) }
.texturedBackground(named: "MapleWoodGrain")
extension View {
func texturedBackground(named name: String) -> some View
{
return self.modifier(PatternBackground(imageName: name))
}
}
public struct PatternBackground: ViewModifier {
var imageName : String
public func body(content: Content) -> some View {
ZStack {
Image(imageName)
.resizable(resizingMode: .tile)
.allowsHitTesting(false)
content
.opacity(0.8)
.allowsHitTesting(true)
}
}
}
Post
Replies
Boosts
Views
Activity
Have you found a solution to this issue? None of my extensions from the App Store show up in System Preferences -> Extensions. This is so frustrating! Xcode's editor needs to be fixed once and for all and then they should leave it. I've written my own extensions just to have basic yank line, paste, restructure variable sections etc. only to have this break over and over.