100 Days of SwiftUI

Day 21

2026-05-09

Project 2, part 2

Starting to build the Flag Guessing Game

Stacking up buttons

  • you can randomize an explicitly defined array by using the .shuffled() modifier
  • wrap VStacks in ZStack so you can add a background color to the app

Showing the player’s score with an alert

  • .alert... modifier goes on the ZStack

Styling our flags

  • there are built-in shape modifiers but they don’t all work the same way. He uses .clipShape(.capsule) which makes a pill-shape. I don’t think that’s appropriate for a flag, so I thought I could use .clipShape(.roundedRect) of some sort. It didn’t work. I ended up with .clipShape(RoundedRectangle(cornerRadius:10)) which is much prettier to me.

Upgrading our design

  • remember to try out your updated designs on multiple device sizes!
  • ooooh. In this video he did use a clip shape with a rounded rectangle. .clipShape(.rect(cornerRadius: 20)) I just didn’t have the right syntax.
  • use Spacer()s to handle different device sizes since they take up available space

Wow is it ever so easy to make ugly apps!

I’m assuming that tomorrow we will be tracking the score…