I try to layer a blur view underneath some text and a picture, which are contained in an HStack, by putting both the blur view and the HStack into a ZStack. I also applied a frame to the blur view to give it my wanted dimensions. But whenever I change the frame width it seems to affect the HStack (pushing it further to the sides) and it's content, which, given the fact that both are contained in a ZStack and is therefore basically lying underneath the HStack, it shouldn't.
After some testing, I found out that the width of the blur view only affects the elements laying above it when they are contained in some kind of stack.
struct AlbumNameView: View {
var body: some View {
ZStack {
BlurView(style: .dark)
.frame(width: 415, height: 155)
.shadow(radius: 2, x: 0, y: 3)
HStack {
Image("shindy nautilus")
.resizable()
.aspectRatio(contentMode: .fit)
.cornerRadius(24)
.frame(width: 130, height: 130)
.shadow(radius: 4)
VStack(alignment: .leading) {
Text("Nautilus")
.foregroundColor(.white)
.font(.largeTitle)
.bold()
.shadow(radius: 1, x: 0, y: 1)
Text("Shindy")
.foregroundColor(.white)
.font(.headline)
//.bold()
.shadow(radius: 1, x: 0, y: 1)
Spacer()
} .frame(width: 230, height: 120, alignment: .leading)
Spacer()
}
.padding(.horizontal)
}
}
}
I don't believe that's a bug so I think that I still fail to grasp why the blur view's width affects the stacks above it and maybe someone could explain how can I change that.