元素之间的偏移量SWIFTUI

元素之间的偏移量SWIFTUI,swift,swiftui,offset,Swift,Swiftui,Offset,我想一个接一个地“连接”我的元素,因为它们之间有一个空格。我试图使用“.offset”属性,但在整个设备中都不起作用。看看 这是主要代码: var主体:一些视图{ ZStack{ 颜色[“浅灰色”]?.边缘识别安全区域(.all) VStack{ HStack{ 文本(“通知”) .font(.system(大小:UIScreen.main.bounds.width*0.05)) .foregroundColor(颜色[“黑色”]) .bold() .padding(.training,UIS

我想一个接一个地“连接”我的元素,因为它们之间有一个空格。我试图使用“.offset”属性,但在整个设备中都不起作用。看看

这是主要代码:

var主体:一些视图{
ZStack{
颜色[“浅灰色”]?.边缘识别安全区域(.all)
VStack{
HStack{
文本(“通知”)
.font(.system(大小:UIScreen.main.bounds.width*0.05))
.foregroundColor(颜色[“黑色”])
.bold()
.padding(.training,UIScreen.main.bounds.width*0.5)
}.frame(宽度:UIScreen.main.bounds.width-40,高度:UIScreen.main.bounds.height*0.08)
.背景(颜色[“白色”])
.clipped()
.阴影(半径:1,x:0,y:0)
HStack{
文本(“访问记录馆”)
.foregroundColor(颜色[“黑色”])
.font(.system(大小:UIScreen.main.bounds.width*0.035))
.bold()
垫片()
文本字段(“#”,文本:$分钟)
.foregroundColor(颜色[“灰色”])
.frame(宽度:UIScreen.main.bounds.width*0.10,高度:UIScreen.main.bounds.width*0.10)
.padding(.training,UIScreen.main.bounds.width*0.10)
.multilitextalignment(.training)
文本(“分钟”)
.foregroundColor(颜色[“黑色”])
.font(.system(大小:UIScreen.main.bounds.width*0.035))
.bold()
}.padding(.all).background(颜色[“白色”).frame(宽度:UIScreen.main.bounds.width*0.892).clipped().shadow(半径:1,x:0,y:0)
HStack{
切换(isOn:$checkIn){
Text(“签入”).foregroundColor(颜色[“黑色]).font(.system(大小:UIScreen.main.bounds.width*0.035)).bold()
}.padding()
如果签入{
}否则{
}
}.background(颜色[“白色”).frame(宽度:UIScreen.main.bounds.width*0.895).clipped().shadow(半径:1,x:0,y:0)
HStack{
切换(签出){
文本(“签出”).foregroundColor(颜色[“黑色”])。字体(.system(大小:
UIScreen.main.bounds.width*0.035)).bold()
}.padding()
如果结帐{
}否则{
}
}.背景(颜色[“白色”).边框(宽度:UIScreen.main.bounds.width*
0.895).剪裁().阴影(半径:1,x:0,y:0)
HStack{
切换(isOn:$CreateVisitions){
文本(“Creación de visita”).foregroundColor(颜色[“黑色])。字体(.system(大小:
UIScreen.main.bounds.width*0.035)).bold()
}.padding()
如果您访问{
}否则{
}
}.背景(颜色[“白色”).边框(宽度:UIScreen.main.bounds.width*
0.895).剪裁().阴影(半径:1,x:0,y:0)
HStack{
切换(isOn:$requestvisions){
文本(“Invitación de visita”).foregroundColor(颜色[“黑色])).font(.system(大小:
UIScreen.main.bounds.width*0.035)).bold()
}.padding()
如有要求,请访问{
}否则{
}
}.背景(颜色[“白色”).边框(宽度:UIScreen.main.bounds.width*
0.895).剪裁().阴影(半径:1,x:0,y:0)
HStack{
切换(提醒){
文本(“RecordTorio”).foregroundColor(颜色[“黑色]).font(.system(大小:
UIScreen.main.bounds.width*0.035)).bold()
}.padding()
如果提醒{
}否则{
}
}.background(颜色[“白色”).frame(宽度:UIScreen.main.bounds.width*0.895).clipped().shadow(半径:1,x:0,y:0)
HStack{
切换(isOn:$notificationsEnabled){
文本(“No deseo recibir notificationaciones”).foregroundColor(颜色[“黑色])).font(.system(大小:
UIScreen.main.bounds.width*0.035)).bold()
}.padding()
.背景(颜色[“白色”])
如果通知已启用{
}否则{
}
}.frame(宽度:UIScreen.main.bounds.width*0.895).clipped().shadow(半径:1,x:0,y:0)
HStack{
按钮(操作:{
}){
HStack{
文本(“瓜达尔”)
.foregroundColor(.白色)
.背景(颜色[“紫色”])
.font(.callout)
.frame(宽度:UIScreen.main.bounds.width*0.3,高度:UIScreen.main.bounds.height*0.025,对齐:。中间)
}
.padding(.all)
.背景(颜色[“紫色”])
.转弯半径(10)
.frame(宽度:UIScreen.main.bounds.width*0.3,高度:UIScreen.main.bounds.height*0.025,对齐:。中间)
}
}.padding()
垫片()
}
}
}

我想你的意思是你不想要盒子之间的垂直空间。将
VStack
替换为
VStack(间距:0)
,使其成为:

var主体:一些视图{
ZStack{
颜色[“浅灰色”]?.边缘识别安全区域(.all)
VStack(间距:0){
HStack{
文本(“通知”)
.font(.system(大小:UIScreen.main.bounds.width*0.05))
.前景