ios – SwiftUI: ZStack side ratio not enforced?


I want to create a view that appears like this:
enter image description here

The sq. is a view that I need to usher in a containing view on this case the ZStack and I need the sq. view to be offset up in order that it will get clipped on the high by no matter quantity of offset I need. I’m having points engaging in this. The code I’ve now could be this:

    VStack {
        
        ZStack {
            
            Colour.crimson

            Rectangle()
                .fill(.grey.opacity(0.6))
                .aspectRatio(1, contentMode: .fill)
                .padding(.horizontal, 100)
                .padding(.backside, 80)
            
        }
        .aspectRatio(288/136, contentMode: .match)
        .border(.yellow)
        .clipped()

        Spacer()
    }
    

It generates this:
enter image description here

The difficulty right here is that .aspectRatio(288/136, contentMode: .match) will not be revered and so every little thing is thrown off.
How can I draw a sq. subview that has a adverse Y offset within the ZStack if I need the ZStack to maintain the 288/136 ratio?

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles