We’ve arrived at day 88 of the 100 Days of SwiftUI! Yesterday, learned how to trigger code by using Timer. Today, we’re looking into designing a single card view and building a stack of cards. Sounds interesting, so let’s dive in right away!
Designing a single card view
In this project we want users to see a card with some prompt text for whatever they want to learn, such as “What is the capital city of Scotland?”, and when they tap it we’ll reveal the answer, which in this case is of course Edinburgh.Hacking with Swift, Paul Hudson (@twostraws)
Before we start, we have to brainstorm and think about what our card should display and what data it should work with. This will define how we’ll design and create this card. For this project, we’ll be asking a question and expect an answer, so those are the two pieces the card will hold and display.
Building a stack of cards in SwiftUI
After we’ve built a single card, the goal is to replicate that card and make multiple to form a stack. Each holding a different question and answer, of course. Right now, we don’t have any way of adding a card, but SwiftUI features helpful functions and methods to accomplish this.
And that’s it for day 88! Tomorrow, we’ll look at how to color views as we swipe, as well as counting down with a timer. It’s no fun if you have infinite time, right? Stay tuned for that and see you tomorrow!