1

Following this solution: https://stackoverflow.com/a/58876712/239219

My Code is fairly similar:

GeometryReader { g in
    var width = CGFloat.zero
    var height = CGFloat.zero
    ZStack(alignment: .topLeading) {
        let platforms = walkExpression(mapRule.objectrule)
        ForEach(platforms) { platform in
            Text(platform.text).padding([.horizontal, .vertical], 4)
                .alignmentGuide(.leading, computeValue: { d in
                    if (abs(width - d.width) > g.size.width)
                    {
                        width = 0
                        height -= d.height
                    }
                    let result = width
                    if platform == platforms.last! {
                        width = 0 //last item
                    } else {
                        width -= d.width
                    }
                    return result
                }).alignmentGuide(.top, computeValue: {d in
                    let result = height
                    if platform == platforms.last! {
                        height = 0 // last item
                    }
                    return result
                })
            
        }
    }
}

But there is a hug gap, empty space under the list, why?

enter image description here

koen
  • 5,383
  • 7
  • 50
  • 89
János
  • 32,867
  • 38
  • 193
  • 353

0 Answers0