슈뢰딩거의 고등어
(10일차) 14일 만에 IOS 앱 끝내기 챌린지 : SwiftUI 버튼 본문
https://www.youtube.com/watch?v=Xx9HjAB-Zz0
버튼을 눌렀을때 반응하는 것을 알 수 있다.
//
// ContentView.swift
// test project
//
// Created by jhmin on 2023/03/01.
//
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
// Button instance with closure
Button("Click me", action: {
print("Hello world")
})
// Button instance with trailing closure
Button("Click me") {
print("Hello world")
}
// Button instance with lable view
Button(action: {
print("Hello world")
}, label: {
HStack{
Image(systemName: "pencil") // sf-symbol
Text("Edit")
}
})
}
}
}
// Only for previews
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
//
// ContentView.swift
// war challenge
//
// Created by jhmin on 2023/02/26.
//
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
Image("background").ignoresSafeArea()
VStack {
Spacer()
Image("logo")
Spacer()
HStack {
Spacer()
Image("card3")
Spacer()
Image("card4")
Spacer()
}
Spacer()
// Change Image into Button
Button(action: {}, label: {
Image("dealbutton")
})
Spacer()
HStack {
Spacer()
VStack {
Text("Player")
.font(.headline)
.foregroundColor(Color.white)
.padding(.bottom, 10.0)
Text("0")
.font(.largeTitle)
.padding()
.fontWeight(.bold)
.foregroundColor(Color.white)
}
Spacer()
VStack {
Text("CPU")
.font(.headline)
.foregroundColor(Color.white)
.padding(.bottom, 10.0)
Text("0")
.font(.largeTitle)
.padding()
.fontWeight(.bold)
.foregroundColor(Color.white)
}
Spacer()
}
Spacer()
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
'14일만에 IOS 앱 끝내기 챌린지' 카테고리의 다른 글
(13일차, 14일차) 14일 만에 IOS 앱 끝내기 챌린지 : 슬롯머신 만들기 (0) | 2023.03.04 |
---|---|
(11일차, 12일차) 14일 만에 IOS 앱 끝내기 챌린지 : State Properties, If 조건문 (0) | 2023.03.04 |
(8일차, 9일차) 14일 만에 IOS 앱 끝내기 챌린지 - Swift 프로그래밍 : 구조체, 객체 (0) | 2023.03.01 |
(3,4,5 일차) 14일 만에 IOS 앱 끝내기 챌린지 - UI 만들기 (0) | 2023.02.26 |
(6일차, 7일차) 14일 만에 IOS 앱 끝내기 챌린지 - Swift 프로그래밍 : 변수/상수, 함수 (1) | 2023.02.26 |
Comments