I have HStack and ScrollView in ZStack, how can I prevent the HStack from covering the bottom of ScrollView? I think there is a modifier to fix this issue, but I can’t remember it.
struct Messages: View {
var body: some View {
ZStack(alignment: .bottom) {
ScrollView {
VStack() {
MessagesList()
}
}
MessageInput()
}
}
}
CodePudding user response:
You can drop the ZStack
and declare the view that sticks to the bottom using the .safeAreaInset
modifier, e.g.:
ScrollView {
// etc.
}
.safeAreaInset(edge: .bottom) {
MessageInput()
}
More information on Hacking with Swift and Apple’s developer docs