Ios HStack中的SwiftUI元素具有不同的高度
我在HStack中有一个按钮和一个文本:Ios HStack中的SwiftUI元素具有不同的高度,ios,swift,button,text,swiftui,Ios,Swift,Button,Text,Swiftui,我在HStack中有一个按钮和一个文本: HStack{ Button(action: {}) { Text(" Text ") .padding() .background(Color.blue) .foregroundColor(.white) .font(.headline) .cornerRadius(5)
HStack{
Button(action: {}) {
Text(" Text ")
.padding()
.background(Color.blue)
.foregroundColor(.white)
.font(.headline)
.cornerRadius(5)
}
Text("")
.frame(minWidth: 0, maxWidth: .infinity)
.padding()
.background(Color.gray)
.font(.headline)
.cornerRadius(5)
}
两个文本具有相同的字体、填充等,但按钮始终高于第二个文本。如何使他们平等?我找到了答案。第二个文本不应该是像“”这样的空字符串,它至少应该包含空格,像“”。我找到了答案。第二个文本不应该是像“”这样的空字符串,它至少应该包含像“”这样的空格