-
#8. 래이아웃(Layout1)SwiftUI 앱만들기 2022. 7. 5. 12:27
#1. MyProjectCard
import SwiftUI
struct MyProjectCard: View {
var body: some View {
VStack(alignment: .leading, spacing: 0){
//Rectangle().frame(height:0)
Text("정대리 유툽 프로젝트")
.font(.system(size: 23))
.fontWeight(.black)
.padding(.bottom, 5)
Text("10AM - 11AM")
.foregroundColor(.secondary)
// .padding(.bottom, 10)
Spacer().frame(height:20)
HStack{
Image("1")
.resizable()
.frame(width:50, height: 50)
.clipShape(Circle()) //원형으로 자르기
.overlay(Circle().stroke(lineWidth: 5)
.foregroundColor(Color.red)) //원형 테두리
Image("2")
.resizable()
.frame(width:50, height: 50)
.clipShape(Circle())
Image("3")
.resizable()
.frame(width:50, height: 50)
.clipShape(Circle())
Spacer()
Text("확인")
.fontWeight(.bold)
.foregroundColor(.white)
.padding()
.frame(width: 80)
.background(Color.blue)
.cornerRadius(20)
}
}
.padding(30)
.background(Color.yellow)
.cornerRadius(20) //귀돌이
}
}
struct MyProjectCard_Previews: PreviewProvider {
static var previews: some View {
MyProjectCard()
}
}
#2.MyBasicCard
import SwiftUI
struct MyBasicCard: View {
var body: some View {
HStack(spacing: 20){
Image(systemName: "flag.fill")
.font(.system(size: 40))
.foregroundColor(.white)
//.frame(width: 100, height: 100)
VStack(alignment:.leading, spacing: 0) {
Divider().opacity(0)
//Rectangle().frame(height:0)
Text("HahaHa")
.fontWeight(.bold)
.font(.system(size: 23))
.foregroundColor(Color.white)
Spacer().frame(height:5)
Text("HahaHa")
.foregroundColor(.white)
}
}
.padding(30)
.background(Color.purple)
.cornerRadius(20) //귀돌이
}
}
struct MyBasicCard_Previews: PreviewProvider {
static var previews: some View {
MyBasicCard()
}
}
#3.ContentView
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack(alignment: .bottomTrailing) {
VStack(alignment:.leading, spacing: 0) {
HStack{
Image(systemName: "line.horizontal.3").font(.largeTitle)
Spacer()
Image(systemName: "person.crop.circle.fill").font(.largeTitle)
}
.padding(20)
Text("정대리 할 일 목록")
.font(.system(size: 40))
.fontWeight(.black)
.padding(.top, 10)
.padding(.horizontal,10)
ScrollView{
VStack{
MyProjectCard()
MyBasicCard()
MyBasicCard()
MyBasicCard()
MyBasicCard()
MyBasicCard()
MyBasicCard()
MyBasicCard()
}.padding()
}
}
.padding(.top, 10)
.padding(.horizontal,10)
Circle().foregroundColor(Color.yellow)
.frame(width:60, height: 60)
.overlay{
Image(systemName: "plus")
.font(.system(size: 30))
.foregroundColor(.white)
}
.padding(10)
.shadow(radius: 20)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
MyProjectCard MyBasicCard ContentView 'SwiftUI 앱만들기' 카테고리의 다른 글
#10. 목록띄우기 (0) 2022.07.07 #9. 래이아웃(Layout2) (0) 2022.07.07 #7-스택(Stacks) (0) 2022.07.05 #6. 이미지(Image) (0) 2022.07.04 #5. 텍스트(Text) (0) 2022.07.04