为什么 Text SwiftUI View 的高度在设置宽度时正确扩展以允许显示内容,但在设置其框架的 maxWidth 时它会折叠成一行?
struct ContentView: View {
var body: some View {
VStack {
Text("Long Text Long Text Long Text Long Text Long Text Long Text Long Text Long Text Long Text")
.background(Color.blue)
Text("Short Text")
.background(Color.green)
}
// .frame(width: 400)
// .frame(maxWidth: 400)
.fixedSize()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
与.frame(width: 400):
![宽度[1]](https://i.stack.imgur.com/lWd5e.png)
与.frame(maxWidth: 400):
有人可以发一个示例代码,告诉我如何让我的游戏画面向上移动,因为我的玩家节点"跳"到y轴上.涂鸦跳?此刻它显然只是直接从屏幕顶部跳出来.
任何帮助使我的"平台"节点从父节点移除自己,然后当他们走出视图底部时重新调整,因为我向上移动屏幕也有帮助.
最后一件事,我如何在初始视图中添加多个节点.[self add child:node]只生一个.
我知道这些可能是业余问题,那就是因为我是业余爱好者.