23.12.13 TIL SwiftUI 7. Frames and Alignments

Hay·2023년 12월 13일
0

SwiftUI_Beginner

목록 보기
3/19

Frames and Alignments

  • 프레임은 원한다면 계속 만들어갈 수 있다. 각 프레임에 백그라운드컬러도 각각 넣어줄 수 있다.
  • 프레임은 기본적으로 투명하기 때문에 디버깅을 하다 막히면 백그라운드컬러를 넣어서 디버깅하면 눈에 보이기 때문에 색 넣고 디버깅하는 것 ㅊㅊ
  • 프레임은 아주 중요한 것이라고 한다
import SwiftUI

struct FrameBootcamp: View {
    var body: some View {
        Text("Hello, World!") //by default, the frame is gonna size to as small as the content.
            //.background(Color.green)
            //.frame(width: 300, height: 300, alignment: .leading)
            //.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
            //.background(Color.red) //we can stack and layer of these frames and backgrounds
        
            .background(Color.red)
            .frame(height: 100, alignment: .top)
            .background(Color.orange)
            .frame(width: 150)
            .background(Color.purple) //이렇게 계속 frame과 background color를 만들어갈 수 있다 ㄷㄷ
            .frame(maxWidth: .infinity, alignment: .leading)
            .background(Color.pink)
            .frame(height: 400)
            .background(Color.green)
            .frame(maxHeight: .infinity, alignment: .top)
            .background(Color.yellow)
        
    }

}

#Preview {
    FrameBootcamp()
}

Frames are crucally important!
apparently...lol

0개의 댓글