SwiftUI 튜토리얼(7)

유재우·2022년 6월 28일
0

SwiftUI 튜토리얼

목록 보기
7/8

VStack

 VStack(alignment: .leading, spacing: 0) {
            // alignment으로 정렬을 맞출 수 있다
            // spacing으로 stack간의 간격을 띄울 수 있다.
            Divider()
                .opacity(0)
            // Divider로 스택의 정렬을 더욱 효과적으로 해주고 투명도를 0 으로 설정하여 구분 선이 보이지 않게 처리
            Text("글자")
                .font(.system(size: 30))
                .fontWeight(.heavy)
            Rectangle()
                .frame(width: 100, height: 100)
                .foregroundColor(.red)
            Rectangle()
                .frame(width: 100, height: 100)
                .foregroundColor(.yellow)
            Spacer()
                .frame(height: 50)
            Rectangle()
                .frame(width: 100, height: 100)
                .foregroundColor(.blue)
        }
//        .edgesIgnoringSafeArea(.all)
        .frame(width: 300)
        .background(Color.green)

HStack

HStack(alignment: .center, spacing: 10){
            Image(systemName: "flame.fill")
                .foregroundColor(.white)
                .font(.system(size: 70))
            Rectangle()
               .frame(width: 100, height: 100)
               .foregroundColor(.yellow)
            Rectangle()
               .frame(width: 100, height: 100)
               .foregroundColor(.blue)
        }
        .padding()
        .background(Color.green)
    }

ZStack

ZStack{
            Rectangle() // 코드 상에 가장 위에 작성된 코드순으로 층이 쌓인다.
                .frame(width: 100, height: 100)
                .foregroundColor(Color.red)
                .zIndex(3) // Z층을 임의로 설정이 가능 기본이 0
            Rectangle()
                .frame(width: 50, height: 50)
                .foregroundColor(Color.yellow)
                .zIndex(3)
            Rectangle()
                .frame(width: 300, height: 300)
                .foregroundColor(Color.blue)
                .zIndex(2)
            }
profile
끝없이 탐구하는 iOS 개발자 유재우입니다!

0개의 댓글