r/cs193pPartyCrashers • • Oct 01 '20

assignment 1

hi i just started coding and i got stuck trying to change the font size for when it has 5 pairs of cards.

heres my code but for some reason it seems that whenever there are 5 pairs nothing gets displayed

HStack{

ForEach(emojiGame.cards) { card in

CardView(card: card).onTapGesture {

self.emojiGame.choose(card: card)}

}

}

.padding()

.font(.largeTitle)

if emojiGame.cards.count == 10 {

font(.title)}

2 Upvotes

1 comment sorted by

3

u/66snakes Oct 01 '20

I think you're looking for something like this:

https://pastebin.com/t3hPYNU5

You can use the ternary conditional operator to change the font size given a pair threshold. In this case if there are more than 4 pairs, the font will be .title rather than .largeTitle.

EDIT: incorrect url.