I'm trying to mask a view displayed inside of the widget to a shape that matches the overall shape. This seems like a perfect place to use the new ContainerRelativeShape() API.
It seems to work fine if I use it in a .background call but doesn't seem to work if I use it as a .clipShape for my subviews. Here is a simplified example showing what I'm doing. This results in a blue rectangle, rather than a blue round rect as I was hoping for.
Is this expected behavior, a bug or am I just using this API incorrectly? Any pointers would be great appreciated.
I am unable to use the .background(ContainerRelativeShape().fill(Color.blue)) approach because the backgrounds of my content are dynamic and so cannot easily be shared across the entire VStack.
This is in iOS 14, Beta 1.
It seems to work fine if I use it in a .background call but doesn't seem to work if I use it as a .clipShape for my subviews. Here is a simplified example showing what I'm doing. This results in a blue rectangle, rather than a blue round rect as I was hoping for.
Code Block struct InsetView: View { var body: some View { VStack { Text("Top") Text("Bottom") } .frame(maxWidth:.infinity, maxHeight: .infinity) .background(Color.blue) .padding(10) .clipShape(ContainerRelativeShape()) } }
Is this expected behavior, a bug or am I just using this API incorrectly? Any pointers would be great appreciated.
I am unable to use the .background(ContainerRelativeShape().fill(Color.blue)) approach because the backgrounds of my content are dynamic and so cannot easily be shared across the entire VStack.
This is in iOS 14, Beta 1.