import SwiftUI
struct PositionView: View {
let text = Text("Hello SwiftUI")
var body: some View {
HStack {
Group {
// 1. original text
text
// ⭐️ 2. offset: frame unchanged
// (⭐️ so is background)
text.offset(x: 0, y: 50)
// ⭐️ 3. if you want to move background too,
// have to apply .background() first.
text
.background(.indigo)
.offset(x: 0, y: 50)
// ⭐️ 4. position: frame changed❗️
text.position(x: 0, y: 50)
}
.padding(.horizontal, 6)
.background(.pink)
.frame(width: 150, height: 150)
.border(.white(0.4))
}
}
}