【问题标题】:Layout SwiftUI List cells from bottom upward从下向上布局 SwiftUI 列表单元格
【发布时间】:2019-09-25 13:30:10
【问题描述】:

有没有办法自定义 SwiftUI List 以便从下到上显示单元格?

与 UITableView 相关的问题:How to populate UITableView from the bottom upwards?

【问题讨论】:

  • 我不确定List 是否(还)有这种能力,但你(显然)可以做的就是在自定义 UIViewRepresentable-View 中使用带有链接答案的 UITableView。 docs

标签: ios swift swiftui


【解决方案1】:
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())
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-28
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    相关资源
    最近更新 更多