繁体   English   中英

滚动到 ScrollView 底部时如何防止覆盖 ZStack 中嵌入的 ScrollView?

[英]How to prevent covering a ScrollView embedded in ZStack when scrolling to the bottom of the ScrollView?

我在 ZStack 中有 HStack 和 ScrollView,如何防止 HStack 覆盖 ScrollView 的底部? 我认为有一个修改器可以解决这个问题,但我不记得了。

struct Messages: View {
    var body: some View {
        ZStack(alignment: .bottom) {
            ScrollView {
                VStack() {
                    MessagesList()
                }
            }
            MessageInput()
        }
    }
}

您可以删除ZStack并使用.safeAreaInset修饰符声明粘在底部的视图,例如:

ScrollView {
  // etc.
}
.safeAreaInset(edge: .bottom) {
  MessageInput()
}

有关使用 SwiftApple 开发人员文档进行黑客攻击的更多信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM