【发布时间】:2021-08-18 09:12:24
【问题描述】:
有人知道如何更改 SceneView 对象的背景颜色吗? 我正在尝试将背景属性放置到 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()
}
}
【问题讨论】:
-
您可以尝试“.colorMultiply(Color.green)”而不是“.background(Color.green)”,但我不确定副作用。
标签: swift xcode swiftui scenekit