iOS Development

ios – Carousel Card view not transfer to left aspect in SwiftUI

Spread the love

I’ve constructed a customized cardView for a procuring cart carousel. For this I designed it in CardView after which go it to Carousel.

The issue I’m going through is my card not transferring to left aspect extra. I attempted completely different paddings and VStack alignment set to .main additionally however its not transfer extra to left aspect. I need to take away additional house from left aspect so I can modify card accordingly.


struct CardView: View {

    personal let identify: String
    personal let description: String
    personal let sort: String
    personal let buttonTitle: String

    init(identify: String, description: String, sort: String, buttonTitle: String) {
        self.identify = identify
        self.description = description
        self.sort = sort
        self.buttonTitle = buttonTitle

    // MARK: - Constants
    personal struct ViewConstants {
        static let screenWidth = Constants.DeviceConfig.screenWidth
        static let cardRatio = 300.0/337.0
        static let cardWidth = 300.0
        static let cardHeight = 369.0
        static let imageHeight: CGFloat = cardWidth/2 +  20
    var physique: some View {
        VStack(spacing: 8) {
            Picture("laptop computer")
                .aspectRatio(contentMode: .match)
                .body(peak: ViewConstants.imageHeight)
                .padding(.prime, 10)
            Textual content("Private Laptop computer")
                .padding(.backside, 2)
            Textual content("The fast brown fox jumps over the lazy canine. The fast brown fox jumps over the lazy canine")
                .padding(.horizontal, 24)
            Button(motion: {
                print("join bin tapped")
                Textual content("Click on for Supply")
                    .body(peak: 10)
                    .font(.system(measurement: 18))
                        RoundedRectangle(cornerRadius: 25)
                            .stroke(, lineWidth: 2)
            .padding(.prime, 4)
            .padding(.backside, 24)
        .body(width: ViewConstants.screenWidth - 100, peak: ViewConstants.cardHeight)

Important Web page I known as CardView with Carousel:

personal var carouselContent: some View {
        VStack(alignment: .main) {
                itemsPadding: 12,
                trailingSpaces: 20 * 5,
                index: $viewModel.Index,
                checklist: viewModel.cartProducts,
                showIndicator: true,
                contentView: { cart in
                    CardView(identify: cart.identify, description: cart.description, sort: cart.sort, buttonTitle: cart.buttonTitle) {}


Important Web page Carousel – I need to transfer left

Leave a Reply

Your email address will not be published. Required fields are marked *