Lädt...


🔧 Scrollable Cards in iOS 18 - #30DaysOfSwift


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Day 9: Smooth Scroll with Scrollable Cards! 🎴

For the ninth post of #30DaysOfSwift series, let's learn Scrollable Cards in SwiftUI.

Scrollable cards or stacks are perfect for showcasing content in a visually appealing, swipeable format.

Link to image example

Let’s build a horizontally scrolling stack of cards that showcases different content!

Steps to Create Scrollable Cards:

1. Set Up the Scrollable Card Layout:

  • We’ll use a ScrollView with a horizontal axis and a set of custom cards that users can swipe through.
import SwiftUI

struct ScrollableCardsView: View {
    let items = [
        CardItem(title: "SwiftUI Essentials", image: "swift"),
        CardItem(title: "Mastering Combine", image: "combine"),
        CardItem(title: "iOS Animations", image: "animation"),
        CardItem(title: "Networking with URLSession", image: "network")
    ]

    var body: some View {
        VStack(alignment: .leading) {
            Text("Trending Courses")
                .font(.largeTitle)
                .fontWeight(.bold)
                .padding(.leading)

            ScrollView(.horizontal, showsIndicators: false) {
                HStack(spacing: 20) {
                    ForEach(items) { item in
                        CardView(item: item)
                            .frame(width: 300, height: 200)
                            .shadow(radius: 5)
                    }
                }
                .padding()
            }
        }
    }
}

struct CardView: View {
    let item: CardItem

    var body: some View {
        ZStack {
            Image(item.image)
                .resizable()
                .aspectRatio(contentMode: .fill)
                .frame(width: 300, height: 200)
                .clipped()

            VStack {
                Spacer()
                Text(item.title)
                    .font(.headline)
                    .padding()
                    .frame(maxWidth: .infinity)
                    .background(Color.black.opacity(0.7))
                    .foregroundColor(.white)
            }
        }
        .cornerRadius(15)
    }
}

struct CardItem: Identifiable {
    var id = UUID()
    var title: String
    var image: String
}

struct ContentView: View {
    var body: some View {
        ScrollableCardsView()
    }
}

How does it look for you? Let me know too!

Happy Coding!

...

🐧 niri v0.1.0-alpha.2 — a scrollable-tiling Wayland compositor, heavily inspired by PaperWM


📈 24.61 Punkte
🐧 Linux Tipps

📰 Hacked on Instagram: A Scrollable Cybercrime


📈 24.61 Punkte
🖥️ Betriebssysteme

🐧 PaperWM: Tiled scrollable window management for Gnome Shell


📈 24.61 Punkte
🐧 Linux Tipps

📰 Google Developer Says Chrome Team is Working on a Scrollable Tabstrip For the Browser


📈 24.61 Punkte
📰 IT Security Nachrichten

🎥 Find scrollable elements quickly with DevTools


📈 24.61 Punkte
🎥 Video | Youtube

🎥 Find scrollable elements quickly with DevTools


📈 24.61 Punkte
🎥 Video | Youtube

🔧 New scroll badge in DevTools: Find scrollable elements faster


📈 24.61 Punkte
🔧 Programmierung

🔧 Flutter Scrolling Techniques: Using GlobalKey and Scrollable.ensureVisible() for Precise Navigation


📈 24.61 Punkte
🔧 Programmierung

🐧 niri 0.1.9: a scrollable-tiling Wayland compositor


📈 24.61 Punkte
🐧 Linux Tipps

🔧 Safari Rendering Issue with Scrollable Flexbox Container with Many Children


📈 24.61 Punkte
🔧 Programmierung

🔧 Comparison of Scrollable Layouts with Flexbox and Grid


📈 24.61 Punkte
🔧 Programmierung

🐧 niri 0.1.7: a scrollable-tiling Wayland compositor, now with full fractional scaling support


📈 24.61 Punkte
🐧 Linux Tipps

🐧 niri v0.1.5: a scrollable-tiling Wayland compositor, with amazing new animations


📈 24.61 Punkte
🐧 Linux Tipps

🐧 niri v0.1.3: a scrollable-tiling Wayland compositor, now with improved touchpad gestures


📈 24.61 Punkte
🐧 Linux Tipps

🔧 Creating a Scrollable Section Navigation in HTML and CSS


📈 24.61 Punkte
🔧 Programmierung

🐧 niri v0.1.0: a scrollable-tiling Wayland compositor


📈 24.61 Punkte
🐧 Linux Tipps

🔧 Upcoming changes to recurring transactions via credit cards and debit cards in India


📈 20.14 Punkte
🔧 Programmierung

🕵️ 330K stolen payment cards and 895K stolen gift cards sold on dark web


📈 20.14 Punkte
🕵️ Hacking

📰 Infineon and Fingerprint Cards partner to enable mass deployment of biometric payment cards


📈 20.14 Punkte
📰 IT Security Nachrichten

🕵️ Backdoor MIFARE Smart Cards Exposes User-Defined Keys On Cards


📈 20.14 Punkte
🕵️ Hacking

🍏 Apple Cards Issued in 2019 Set To Expire, Replacement Titanium Cards on the Way


📈 20.14 Punkte
🍏 iOS / Mac OS

📰 The 5 best credit cards of 2022: Top cards compared


📈 20.14 Punkte
📰 IT Nachrichten

🍏 Apple Cash virtual cards appear in iOS 17.4 developer beta


📈 13.3 Punkte
🍏 iOS / Mac OS

📰 iOS Vulnerability Exposes iPhone Users’ Passwords and Credit Cards


📈 13.3 Punkte
📰 IT Security Nachrichten

⚠️ [dos] Microsoft Outlook VCF cards - Denial of Service (PoC)


📈 10.07 Punkte
⚠️ PoC

📰 iTunes-Rabatt im März 2023: Aktuelle Angebote für günstige Apple Gift Cards


📈 10.07 Punkte
📰 IT Nachrichten

🍏 Save up to 43% on memory cards & portable drives from SanDisk, Samsung & more


📈 10.07 Punkte
🍏 iOS / Mac OS

📰 BidenCash darkweb market gives 1.9 million credit cards for free


📈 10.07 Punkte
📰 IT Security Nachrichten

🔧 Create a Stacking Cards Waterfall Effect with Tailwind and Alpine.js


📈 10.07 Punkte
🔧 Programmierung

matomo