考虑这个简单的例子:
import SwiftUI
struct RotationExample: View {
var body: some View {
ZStack {
Color.red
Text("Text I want to hide")
.font(.system(size: 48))
}
.frame(width: size, height: size)
.rotation3DEffect(Angle.degrees(180), axis: (x: 0, y:1, z: 0))
}
}
struct RotationExample_Previews: PreviewProvider {
static var previews: some View {
RotationExample()
}
}
运行此代码时,文本以相反的方式显示。我以为当应用旋转时,将尊重图层(即,前景图层将在背景后面消失)
是否可以隐藏背面旋转超过90度的视图,或者以某种方式使图层在旋转过程中反转?我尝试使用.drawingGroup()
并设置.background
修饰符,但均无效。
``只是对绘图上下文的一种转换,即。 如何绘制内容