使用SwiftUI rotation3DEffect是否可以隐藏背面?

问题描述 投票:1回答:1

考虑这个简单的例子:

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()
  }
}

运行此代码时,文本以相反的方式显示。我以为当应用旋转时,将尊重图层(即,前景图层将在背景后面消失)

Screenshot showing red rectangle with 'Text I want to hide' backwards on top

是否可以隐藏背面旋转超过90度的视图,或者以某种方式使图层在旋转过程中反转?我尝试使用.drawingGroup()并设置.background修饰符,但均无效。

ios 3d swiftui
1个回答
0
投票

``只是对绘图上下文的一种转换,即。 如何绘制内容

© www.soinside.com 2019 - 2024. All rights reserved.