The app only supports the potrait mode. Two questions should be displayed, but they are rotated accordingly. So the players can see the questions well, no matter where they sit.
Anyway, it seems that the bounding box is not rotated while rotating.
ZStack {
HStack {
GeometryReader { proxy in
Text(challenge)
.rotationEffect(Angle(degrees: 90), anchor: .center)
.frame(maxWidth: proxy.size.height, minHeight: proxy.size.width)
.foregroundColor(.red)
.font(.largeTitle)
.background(Color.blue)
}
Spacer()
GeometryReader { proxy in
Text(challenge)
.rotationEffect(Angle(degrees: 270), anchor: .center)
.frame(maxWidth: proxy.size.height, minHeight: proxy.size.width)
.foregroundColor(.red)
.font(.largeTitle)
.background(Color.blue)
}
}
}
I have tried many different things. I left out the GeometryReader and worked with 'fixedSize()`. Then I get a one-liner that goes across the screen.
I have also tried this solution, but it does not work as expected.
My result is always a text which does not use the full width. (The overlapping is just another mistake, but I will definitely get that under control).

What I actually want to have:

Here is a demo of possible approach. Prepared with Xcode 12.1 / iOS 14.1

struct DemoView: View {
var body: some View {
HStack {
RotatedText(text: lorem, angle: Angle(degrees: 90))
RotatedText(text: lorem, angle: Angle(degrees: -90))
}
}
}
struct RotatedText: View {
let text: String
let angle: Angle
var color: Color = .blue
var body: some View {
color.overlay(
GeometryReader { gp in
VStack {
Text(text)
.frame(width: gp.size.height, height: gp.size.width)
.rotationEffect(angle)
}.frame(width: gp.size.width, height: gp.size.height)
}
)
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With