I am trying to trailing align rotated texts (top aligned after rotation?). I have tried different combinations of the HStack alignment parameter
, each Text's alignmentGuide() ViewModifier
and a custom VerticalAlignmentGuide
but was not able to achieve the desired result.
I did refrain from using the .frame() ViewModifier
since the text's scale factor might change depending on the amount of Text Views.
Needed alignment shown with red line:
Base code:
HStack {
VStack {
Spacer()
Rectangle()
.fill(Color.green)
.frame(height: 80)
Text("Text 1")
.rotationEffect(.degrees(-90))
.padding(.top, 30)
}
VStack {
Spacer()
Rectangle()
.fill(Color.green)
.frame(height: 80)
Text("Text 2")
.rotationEffect(.degrees(-90))
.padding(.top, 30)
}
VStack {
Spacer()
Rectangle()
.fill(Color.green)
.frame(height: 80)
Text("Text 34")
.rotationEffect(.degrees(-90))
.padding(.top, 30)
}
}