Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create sticky bottom in SwiftUI?

Tags:

ios

swift

swiftui

I am trying to create sticky footer in swiftUI where other part of screen is scrollable but in footer there is one view with buttons and other element which should be fixed.

enter image description here

Thank You for help.

like image 946
Rahul Avatar asked Jan 25 '26 23:01

Rahul


1 Answers

From iOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+,tvOS 15.0+, watchOS 8.0+ you can use safeAreaInset

For example:

struct ContentView: View {
    var body: some View {
        VStack {

        }
        .safeAreaInset(edge: .bottom, spacing: 0) {
            footerView
        }
    }

    var footerView: some View {
        // your content
    }
}
like image 181
Alexander Khitev Avatar answered Jan 28 '26 16:01

Alexander Khitev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!