SwiftUI .offsetと.positionの覚書き(.topLeadingの場合)

条件:ZStack(alignment: .topLeading)

.offset:部品(View)左上の位置
.position:部品(View)真ん中の位置

import SwiftUI

struct MainView: View {
    var body: some View {
        GeometryReader { geometry in
            ZStack(alignment: .topLeading) {
                Text("1234567890")
                    .font(Font.system(size: 48))
                    .foregroundStyle(.blue)
                    .border(.blue, width: 1)
                    .offset(x: 0, y: 0)
                Text("1234567890")
                    .font(Font.system(size: 48))
                    .foregroundStyle(.red)
                    .border(.blue, width: 1)
                    .position(x: 0, y: 0)
            }
        }
    }
}

SwiftSwift,SwiftUI

Posted by shi-n