下面是两个文本框在SwiftUI中的呈现方式,但我希望它们都是全宽的:
这是我的密码:
VStack(spacing: 20){
//Help ---
VStack(alignment: .leading, spacing:10){
Text("Help").h2()
Text("Please view our online user guide before contacting us since we answer most questions there.")
.lineLimit(nil) //Make the text wrap
.prefsText()
Button("Online Help"){
openURL(URL(string: "https://avid.pro/help")!)
}.foregroundColor(Color(accentColor))
.buttonStyle(PlainButtonStyle())
.prefsLink()
}.unoBoxRoundPad()
.frame(maxWidth: .infinity)
//Support ---
VStack(alignment: .leading, spacing:10){
Text("Support").h2()
Text("Email us if you need to submit a bug or get specialized help. It may take us a few days to get back to you.")
.lineLimit(nil) //Make the text wrap
.prefsText()
Button("Email Us"){
openURL(URL(string: "mailto:help@avid.pro")!)
}.foregroundColor(Color(accentColor))
.buttonStyle(PlainButtonStyle())
.prefsLink()
}.unoBoxRoundPad()
.frame(maxWidth: .infinity)
}.background(Color.yellow) //For testing
我一辈子都搞不懂为什么它们的宽度不一样。
.unoBoxRoundPad()
是添加以下共享样式的视图修改器:
.padding(20)
.background(Color("UnoDark"))
.cornerRadius(7)
如果我把
.frame(maxWidth: .infinity)
上
Text()
而不是在桌子上
VStack
,它看起来更接近了一点,但是它忽略了包含视图的
padding()
:
你知道我做错了什么吗?