www.youtube.com/watch?v=jbtqIBpUG7g&feature=youtu.be
-- 프로젝트 시작
-- 소스
//
// ContentView.swift
// Memorize
//
// Created by user on 2021/01/15.
//
// UI 작업관련 패키지
import SwiftUI
// View Function
struct ContentView: View {
// Swift 모든 변수에는 특정 유형이 있음 - 기본 방식
//
var body: some View {
HStack{ // 위로 쌓임
ForEach(0..<4) { index in
CardView(isFaceUp: false)
}
}
.padding()
.foregroundColor(Color.orange)
.font(Font.largeTitle)
}
}
struct CardView: View {
var isFaceUp: Bool
var body: some View {
ZStack { // 오른쪽으로 쌓임
if isFaceUp {
RoundedRectangle(cornerRadius: 10.0)
.fill(Color.white)
RoundedRectangle(cornerRadius: 10.0)
.stroke(lineWidth: 3) // 테두리
Text("➰")
} else {
RoundedRectangle(cornerRadius: 10.0)
.fill()
}
}
}
}
// Swift UI Preview 화면 띄우는 것
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
'IOS' 카테고리의 다른 글
3. IOS 강의 Animation (0) | 2021.01.18 |
---|---|
3. IOS 강의 ViewBuilder Shape ViewModifier (0) | 2021.01.18 |
3. IOS 강의 Grid enum Optionals (0) | 2021.01.18 |
3. IOS 강의 Reactive UI + Protocols + Layout (0) | 2021.01.17 |
3. IOS 강의 MVVM and the Swift Type System (0) | 2021.01.17 |