SwiftUI - Resizable List height that dependent on an element count
问题 I have some troubles with dynamically changing List height that dependent on elements count. I tried this solution but it didn't work. List { ForEach(searchService.searchResult, id: \.self) { item in Text(item) .font(.custom("Avenir Next Regular", size: 12)) } }.frame(height: CGFloat(searchService.searchResult.count * 20)) 回答1: TL;DR This is not how the designers of SwiftUI want you to use lists. Either you will have to come up with a hacky solution that will probably break in the future (see