HomeiOS Developmentios - My card background coloration exceeds the display screen

ios – My card background coloration exceeds the display screen


enter picture description right here

The background coloration set on the prime of my third card and the underside of my ninth card within the preview display screen exceeds the border of the cardboard(I’m listening the CS193P)

right here is my code

import SwiftUI

struct CardView: View {
    
    let cardShape: CardViewShape
    let coloration: Colour
    let elementsNum: Int
    let fillingMethod: FillingMethod
    
    
    var physique: some View {
        GeometryReader { geometry in
            VStack(alignment: .heart, spacing: 5) {
                Spacer()
                ForEach(1..<elementsNum+1, id:.self) {index in
                    cardView(for: cardShape, in: geometry)
                }
                Spacer()
            }
            .body(width: geometry.dimension.width)
            .border(Colour.orange, width: 5)
            .background(Colour.inexperienced)
        }
        .aspectRatio(2/3, contentMode: .match)
    }
    
    @ViewBuilder
    personal func cardView(for cardShape: CardViewShape, in geometry: GeometryProxy) -> some View {
        change (cardShape) {
        case .circle:
            let width = min(geometry.dimension.width, geometry.dimension.top/CGFloat(elementsNum)) - 10
            Circle()
                .fill(mode: fillingMethod, coloration: coloration)
                .body(maxWidth: width)
        case .rectangle:
            let width = geometry.dimension.width * 0.65
            let top = geometry.dimension.top / 5
            Rectangle()
                .fill(mode: fillingMethod, coloration: coloration)
                .body(width: width, top: top)
        case .diamond:
            Diamond()
                .fill(mode: fillingMethod, coloration: coloration)
        }
    }
}





RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments