Hello guys,
everything was working perfectly but I can't do a thing please help me.
I was trying to put into this Rectangle some text , I've tried several lines of code but I can't put the Text INTO the rectangle. Can someone help me?
Here's the code
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State var flipped = false
var body: some View {
Group {
RoundedRectangle(cornerRadius: 20)
.frame(width: 140, height: 170)
.foregroundColor(self.flipped ? .red : .orange)
.padding()
.rotation3DEffect(self.flipped ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))
.animation(.default)
.onTapGesture {
self.flipped.toggle()
}
}
}
}
PlaygroundPage.current.setLiveView(ContentView())
struct ContentView: View {
@State private var flipped = false
var body: some View {
Group {
RoundedRectangle(cornerRadius: 20)
.frame(width: 140, height: 170)
.foregroundColor(flipped ? .yellow : .purple)
.padding()
.overlay(Text("Hello, world!").rotation3DEffect(Angle(degrees: flipped ? 180 : 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0))).opacity(flipped ? 1 : 0))
.rotation3DEffect(flipped ? Angle(degrees: 180): Angle(degrees: 0), axis: (x: CGFloat(0), y: CGFloat(10), z: CGFloat(0)))
.animation(.default, value: flipped)
.onTapGesture {
flipped.toggle()
}
}
}
}
Is this ok?