4

Is there a way to customize SwiftUI List so cells are displayed from bottom to top?

Related question with UITableView: How to populate UITableView from the bottom upwards?

randomor
  • 5,329
  • 4
  • 46
  • 68
  • 1
    I'm not sure if `List` has this ability (yet) but what you (obviously) could do is to just use a UITableView with the linked answer inside a custom UIViewRepresentable-View. [docs](https://developer.apple.com/documentation/swiftui/uiviewrepresentable) – thisIsTheFoxe Sep 25 '19 at 13:36

1 Answers1

2
struct FlipEffect: GeometryEffect {
    func effectValue(size: CGSize) -> ProjectionTransform {
        let t = CGAffineTransform(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: size.height)
        return ProjectionTransform(t)
    }
}

struct ContentView: View {
    var body: some View {
        List(0..<100) { item in
            Text("hello, world")
                .modifier(FlipEffect())
        }
        .modifier(FlipEffect())
    }
}
Shintaro Abe
  • 163
  • 6
  • Ummm... that's a really cool hack! But it literally does a full flip transform. If you have text, you'll need to stand on your head with a mirror to read it, lol. But so cool, gonna keep this trick around, thanks! – moodboom Jul 15 '22 at 19:08