The Simulator does not execute the code the last version 12 worked. I will not prepare my device the last version of 12 did. The code below worked on the simulator and real iPad Air 4th gen. 1.) I can not even get the iPad Air connected with nothing running on the iPad. 2.) The simulators can not run the CardView correctly. When going from isFaceUp true to false the back ground to not complete refresh in the simulator or active preview. The right top card works but it begins not the refresh the top of the card as it goes left on the screen and get worse when the cards on that are further down the screen. The Cards refresh less and less of the top of the card as it gets lower on the screen on the left half of the screen. Boarder shows properly but red does not completely always fill when completely when isFaceUp goes false for every card. The ones on the top left work but as you go down and left less of the top of the card fills in the "RoundedRectangle(cornerRadius: 20.0)" I guess the "LazyVGrid(columns: [GridItem(.adaptive(minimum: 68))])" fails to work properly. Do not plan to upgrade the iPad Air since I do not trust Apple code now!
//
// ContentView.swift
// Memorize
//
// Created by Reigh Jack on 8/19/21.
// using CS193P Spring 2021
//
import SwiftUI
struct ContentView: View {
var emojis = ["🚲", "🚂", "🚁", "🚜", "🚕" ,"🏎", "🚖", "🚐", "🚒", "✈️", "🚀", "⛵️", "🛸", "🛶", "🚌", "🏍", "🛺", "🚠", "🛵", "🚗", "🚚", "🚇", "🛻", "🚝"]
@State var emojiCount = 20
var body: some View {
VStack{
ScrollView {
LazyVGrid(columns: [GridItem(.adaptive(minimum: 68))]) {
ForEach(emojis[0..<emojiCount], id: .self ) { emoji in
CardView(content: emoji)
.aspectRatio( 2/3, contentMode: .fit)
}
}
}
.foregroundColor(.red)
}
.padding(.horizontal)
}
}
struct CardView: View {
var content: String
@State var isFaceUp: Bool = false
var body: some View {
ZStack{
let shape = RoundedRectangle(cornerRadius: 20.0)
if isFaceUp {
shape.fill().foregroundColor(.white)
shape.strokeBorder(lineWidth: 3)
Text(content).font(.largeTitle)
} else {
shape.fill()
}
}
.onTapGesture { isFaceUp = !isFaceUp }
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.preferredColorScheme(.dark)
ContentView()
.preferredColorScheme(.light)
}
}