我在HStack中有一个按钮和一个文本:
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)
}
两个文本都具有相同的字体,填充等,但是按钮始终高于第二个文本。如何使它们相等?
答案 0 :(得分:0)
我找到了答案。第二个文本不应为空字符串,例如“”,它至少应包含空格,例如“”。