IOS/SwiftUI
(SwiftUI)07.Stack 정리
프린이0218
2021. 4. 27. 15:28
-VStack-
//
// MyVStack.swift
// SwiftUI_Statcks_tuturial
//
// Created by devdepot on 2021/04/27.
//
import SwiftUI
struct MyVstack : View {
var body: some View {
VStack(alignment: .center, spacing: 0){
// Spacer()
Text("글자")
.font(.system(size: 30))
.fontWeight(.heavy)
Divider().opacity(0) //선 안보이게
Rectangle()
.frame(width : 100,height: 100)
.foregroundColor(Color.red)
Rectangle()
.frame(width : 100,height: 100)
.foregroundColor(Color.yellow)
Spacer()
.frame(height:50)
Rectangle()
.frame(width : 100,height: 100)
.foregroundColor(Color.blue)
// Spacer()
// Spacer()
}
// .edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/)
.frame(width: 300)
.background(Color.green)
}
}
-HStack-
//
// MYHStack.swift
// SwiftUI_Statcks_tuturial
//
// Created by devdepot on 2021/04/27.
//
import SwiftUI
struct MYHStack : View {
var body: some View{
HStack(alignment: .center) {
// Divider()
// Rectangle()
// .frame(width: 100)
// .foregroundColor(Color.red)
// Rectangle()
// .frame(width: 100, height: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/)
// .foregroundColor(Color.red)
Image(systemName: "flame.fill")
.foregroundColor(.white)
.font(.system(size: 70))
Rectangle()
.frame(width: 100, height: 100)
.foregroundColor(Color.yellow)
Rectangle()
.frame(width: 100, height: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/)
.foregroundColor(Color.blue)
}
.padding()
.background(Color.green)
}
}
struct MYHStack_Previews: PreviewProvider {
static var previews: some View {
MYHStack()
}
}
_ZStack-
//
// MyZstack.swift
// SwiftUI_Statcks_tuturial
//
// Created by devdepot on 2021/04/27.
//
import SwiftUI
struct MyZstack : View {
var body : some View{
ZStack{
Rectangle()
.frame(width:100,height: 100)
.foregroundColor(Color.red)
.zIndex(1) //깊이 레벨 설정
Rectangle()
.frame(width:50,height: 50)
.foregroundColor(Color.green)
Rectangle()
.frame(width:25,height: 25)
.foregroundColor(Color.blue)
}
}
}
struct MyZstack_Previews: PreviewProvider {
static var previews: some View {
MyZstack()
}
}