Press "Enter" to skip to content

【SwiftUI】Textの表示位置まとめ

var body: some View {
    let columns = Array(repeating: GridItem(), count: 3)
    
    LazyVGrid(columns: columns, spacing: 0) {
        Text("topLeading")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .topLeading)
            .border(Color.black)
        Text("top")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .top)
            .border(Color.black)
        Text("topTrailing")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .topTrailing)
            .border(Color.black)
        Text("leading")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .leading)
            .border(Color.black)
        Text("center")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .center)
            .border(Color.black)
        Text("trailing")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .trailing)
            .border(Color.black)
        Text("bottomLeading")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .bottomLeading)
            .border(Color.black)
        Text("bottom")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .bottom)
            .border(Color.black)
        Text("bottomTrailing")
            .border(Color.red)
            .frame(width: 100, height: 100, alignment: .bottomTrailing)
            .border(Color.black)
    }
}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です