I need to disable scroll in tableView and increase the height according to its content. below is my code for table view in swiftUI please draw me guidance
var body: some View {
List{
ForEach(testData){ data in
VStack(alignment: .leading){
HStack{
Image(data.name)
.resizable()
.frame(width: 50, height: 50, alignment: .leading)
VStack(alignment: .leading){
Text(data.name)
.bold()
Text(data.bio)
.font(.subheadline)
}
}
}
}
}
.offset(y:-60)
.padding(8)
}
You could do this by removing the List and swapping it for a VStack. Then you would use a divider at the end of each VStack of elements and you would add horizontal padding and this gives the same effect as a list, but makes it not scrollable and it would adjust height depending on the elements.