Tuesday, January 9, 2024
HomeiOS Developmentios - My card background coloration exceeds the display

ios – My card background coloration exceeds the display


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 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 {
        swap (cardShape) {
        case .circle:
            let width = min(geometry.dimension.width, geometry.dimension.peak/CGFloat(elementsNum)) - 10
            Circle()
                .fill(mode: fillingMethod, coloration: coloration)
                .body(maxWidth: width)
        case .rectangle:
            let width = geometry.dimension.width * 0.65
            let peak = geometry.dimension.peak / 5
            Rectangle()
                .fill(mode: fillingMethod, coloration: coloration)
                .body(width: width, peak: peak)
        case .diamond:
            Diamond()
                .fill(mode: fillingMethod, coloration: coloration)
        }
    }
}







Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments