有谁知道如何更改SceneView对象的背景颜色吗?我尝试将background属性放置到SceneView中,但它不会改变它,仍然使用默认背景。In this case I wanted to the background be green, but it's keeps gray/white
import SwiftUI
import SceneKit
struct ContentView: View {
var body: some View {
ZStack{
Color.red
SceneView(
scene: SCNScene(named: "Earth.scn"),
options: [.autoenablesDefaultLighting,.allowsCameraControl]
)
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height/2, alignment: .center)
.background(Color.green)
.border(Color.blue, width: 3)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
字符串
1条答案
按热度按时间8aqjt8rx1#
您看到的灰色来自
SCNScene
的background
属性。您需要将其设置为UIColor.green
。字符串
测试结果:
的数据