CardView

Starting with the cards, we will create a struct view that takes color and a number. The cards are going to be RoundedRectangles with the filled color and a Text view with the numbers stacked on top of each other in a ZStack.

I have a background attribute on the RoundedRectangle that takes a white color as a view. This is because I’m giving colors to the CardView that have opacity attributes with the value 0.3. If you are using colors with the opacity value of 1.0, then there is no need for the background color.

struct CardView: View {
	    let num : Int
	    let color : Color
	    var body: some View {
	        ZStack {
	            RoundedRectangle(cornerRadius: 20)
	                .fill(self.color)
	                .shadow(color: self.color.opacity(1), radius: 10)
	                .background(Color.white)
	                .frame(width: 230, height: 250)
	            Text("\(self.num)")
	                .font(.system(size: 35))
	                .bold()
	        }
	    }
	}

#swiftui #programming #mobile-development #xcode #swift

Build a 3D Card Scrolling Animation in SwiftUI
5.30 GEEK