我有一个导航列表,每个列表项都采用这种格式:
HStack {
TextField("Insert something here.",text: self.$userData.pages[i].title)
.border(Color.blue)
Spacer()
}
这将导致以下视图:
The touchable area is highlighted by the blue border and it takes the whole width of the row
这样做的问题是,尽管列表项是导航链接,但用户单击该项的任何位置都将导致他们编辑文本内容。我想要的是TextField
,其宽度与Text
相同:
The blue border wraps the text instead of taking the max width
因此,如果用户在TextField
之外单击,导航将起作用,但是如果他们单击on,将允许他们编辑文本。 (以上视图带有Text
字段。)>
抱歉,我问的问题不清楚或不好。我是Stack Overflow和SwiftUI的新手。
我有一个导航列表,每个列表项都采用这种格式:HStack {TextField(“在此处插入内容。”,文本:self。$ userData.pages [i] .title).border(Color.blue).. 。
无需道歉,您的问题很明确。您可以使用fixedSize()