This is comment for paste
cardView
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SwiftUI
- struct PagingCardView: View {
- let items: [String]
- @State private var currentIndex = 0
- var body: some View {
- TabView(selection: $currentIndex) {
- ForEach(0..<items.count, id: \.self) { index in
- CardView(text: items[index])
- .tag(index)
- }
- }
- .tabViewStyle(PageTabViewStyle())
- .frame(height: 200)
- .indexViewStyle(PageIndexViewStyle(backgroundDisplayMode: .always))
- }
- }
- struct CardView: View {
- let text: String
- var body: some View {
- VStack {
- Text(text)
- .font(.title)
- .padding()
- .background(Color.blue)
- .cornerRadius(10)
- .foregroundColor(.white)
- }
- .frame(maxWidth: .infinity, maxHeight: .infinity)
- .background(Color.gray.opacity(0.2))
- .cornerRadius(10)
- .padding()
- }
- }
- struct ContentView: View {
- var body: some View {
- PagingCardView(items: ["Card 1", "Card 2", "Card 3"])
- }
- }
- @main
- struct MyApp: App {
- var body: some Scene {
- WindowGroup {
- ContentView()
- }
- }
- }
Add Comment
Please, Sign In to add comment