我的工具栏视图导致了问题。致电给 Text( "" ).toolbar 正在将添加死空间放置在顶部 内容窗口空间。我尝试过替换 Text() 与其他项目(表单、滚动视图等)但它们不是 我想要的图形用户界面。天哪,我不想要文本对象,但是 .toolbar 工作需要接缝。
工具栏应该显示在窗口的标题栏中,事实也确实如此。
我不明白我在这里做错了什么。取消注释 .borders 显示了这些对象周围的紧密包装。 添加 ABC 作为文本,显示顶部的死角 ABC 位于屏幕中央。这当然是一个 我的代码的简化版本。
struct ToolbarView: View {
var body: some View {
HStack {
Text( "" )
.toolbar
{
Button( "Hi!", systemImage: "rectangle" )
} // End of toolbar
.border(Color.purple)
} // End of Stack
}
}
我这样称呼:
struct ContentView: View {
var body: some View {
ToolbarView( )
GeometryReader { geometry in
HStack {
Group {
Text( "For Content" )
}
.frame( maxWidth: .infinity, maxHeight: .infinity ) // required to fill space
.background(Color.white)
// .border(Color.blue, width: 4)
Group {
Text( "My panel" )
}
.frame( width: 300 )
.background( .black )
.animation(.easeInOut( duration: 0.5 )) // TODO: Update this
.transition(.move(edge: .trailing))
// .border(Color.pink, width: 4)
}
}
}
}
struct MyCADApp: App {
var body: some Scene {
WindowGroup {
ContentView( )
.frame( minWidth: 1000, minHeight: 600 )
}
}
}
尝试用
Text( "" )
替换您的 VStack{}
,对我有用。