Hi I'm novice in SwiftUI and have a problem.
I want to make a bottom bar (reusable module) to use in multiple Views.
But its position is different in every single views because of its sibling views
These are what I tried:
- GeometryReader But Each View's geometry is different.
- overlay & position(x:y:) This also doesn't work
- ZStack
My questions are
- How can I make fixed position View? (like position: absolute in css)
- What is the normal solution for this problem?
- Is there any helpful references for SwiftUI?
I want use this Module as Bottom Button Bar
struct BaseBottomButton: View {
let screen = UIScreen.main.bounds
var body: some View {
Button(action: {
print("hello")
}) {
Text("Hello")
}
.frame(width: self.screen.width ,height: 40)
.background(Color.red)
}
}
In this view, it works

struct ContentView: View {
var body: some View {
GeometryReader { proxy in
VStack {
VStack {
Text("What")
.frame(width: 400, height: 50)
.background(Color.green)
}
Spacer()
Group {
VStack {
Text("Some Text")
Text("")
.frame(width: 200, height: 200)
.background(Color.yellow)
}
}
Spacer()
BaseBottomButton()
}
}
}
}
But in this complex view, it doesn't work

struct NewView: View {
var body: some View {
GeometryReader { geometry in
ScrollView(showsIndicators: false) {
VStack(spacing: 0) {
Text("hello")
.frame(width: 200, height: 200)
.background(Color.blue)
ZStack(alignment: .leading) {
VStack {
Spacer()
.frame(height: 24)
}
.padding(.leading, 20)
.padding(.bottom, 138)
Text("some box")
.frame(width: 200, height: 100)
.background(Color.yellow)
}
.frame(minWidth: 0, maxWidth: .infinity)
.background(Color.gray)
Spacer(minLength: 40)
}
BaseBottomButton()
}
}
}
}