Playground에서 App gallery 있는 것들 중 About Me를 해보는 중이다
App /AboutMeApp
/ContentView
/FavoritesView ... ✅
/FunFactsView ... ✅
/HomeView ... ✅
/StoryView ... ✅
/YourTab
import SwiftUI
struct FunFactsView: View {
/*#-code-walkthrough(FunFactsView.funFacts)*/
var allFunFacts =
[
"There are 12,600 people in my town.",
"There is a farmers market every Wednesday in the summer.",
"There is a creek that runs through town."
]
/*#-code-walkthrough(FunFactsView.funFacts)*/
/*#-code-walkthrough(FunFactsView.stateVariable)*/
@State private var funFact = ""
/*#-code-walkthrough(FunFactsView.stateVariable)*/
var body: some View {
/*#-code-walkthrough(FunFactsView.color)*/
ZStack {
Image("Green")
VStack {
/*#-code-walkthrough(FunFactsView.color)*/
Text("Fun Facts")
.font(.largeTitle)
/*#-code-walkthrough(FunFactsView.textView)*/
Text(funFact)
.font(.title)
.frame(maxWidth: 400, minHeight: 300)
/*#-code-walkthrough(FunFactsView.textView)*/
/*#-code-walkthrough(FunFactsView.button)*/
Button("Show Random Fact") {
funFact = allFunFacts.randomElement() ?? "No Fun."
}
/*#-code-walkthrough(FunFactsView.button)*/
/*#-code-walkthrough(FunFactsView.button.modifiers)*/
.padding()
.foregroundColor(.white)
.background(.blue)
.clipShape(RoundedRectangle(cornerRadius: 15))
.shadow(radius: 15)
.font(.title2)
}
.padding()
}
}
}
struct FunFactsView_Previews: PreviewProvider {
static var previews: some View {
FunFactsView()
}
}
👀결과