如何在swiftUI中调整HStack元素之间的间距? [英] How to adjust spacing between HStack elements in swiftUI?
本文介绍了如何在swiftUI中调整HStack元素之间的间距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我添加了spacer(minLength:5),但是它需要最小长度我可以指定文本之间的间距.我已经附上了一个屏幕截图,以供参考,我希望减少内部hstack之间的间距.
I have added spacer(minLength: 5) but it takes the minlenght can I specify the spacing between the text. I have attached a screenshot for reference I want to reduce the spacing between inner hstack.
HStack {
Image("Rhea").resizable().cornerRadius(25).frame(width: 50.0, height: 50.0)
VStack(alignment: .leading) {
Text("How to enjoy your life without money").bold().font(.system(size: 20))
HStack {
Text("Lets create")
Spacer(minLength: 5)
Text("3K views")
Spacer(minLength: 5)
Text("3 hours ago")
}
}
}
推荐答案
向HStack本身添加间距属性.间距为10:
Add spacing attribute to the HStack itself. For a spacing of i.e. 10:
HStack {
Image("Rhea").resizable().cornerRadius(25).frame(width: 50.0, height: 50.0)
VStack(alignment: .leading) {
Text("How to enjoy your life without money").bold().font(.system(size: 20))
HStack(spacing: 10) {
Text("Lets create")
Text("3K views")
Text("3 hours ago")
}
}
}
这篇关于如何在swiftUI中调整HStack元素之间的间距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文