SwiftUI HStack with wrap and dynamic height(带有换行和动态高度的 SwiftUI HStack)
问题描述
我有这个视图来显示我从
好的,这里有一些更通用的 &改进的变体(针对最初在
I have this view to show text tags on multiple lines which I got from SwiftUI HStack with Wrap, but when I add it in a VStack the tags overlap any other view that I put below. The tags are shown properly but the height of the view itself is not calculated inside the VStack. How can I make this view use the height of is content?
Example code:
Result:
Ok, here is a bit more generic & improved variant (for the solution initially introduced in SwiftUI HStack with Wrap)
Tested with Xcode 11.4 / iOS 13.4
Note: as height of view is calculated dynamically the result works in run-time, not in Preview
这篇关于带有换行和动态高度的 SwiftUI HStack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!