Skip to content

nicoreese/StretchyHeaderScrollView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StretchyHeaderScrollView

me

Want to implement a scroll view with a stretchy header in SwiftUI? But you don't want to use GeometryReader? And you don't want to have a fixed height for the header? Look no further.

  • No use of GeometryReader
  • Super easy to adopt
  • Header uses its natural height, no hardcoded values needed
  • Super stretchy, super smooth
  • Requires iOS 18, due to use of onScrollGeometryChange to get the scroll offset

Use with Swift Package Manager

https://github.com/nicoreese/StretchyHeaderScrollView.git

How to use

StretchyHeaderScrollView {
    // Other content elements that should be displayed below the header, like the Hello text in the preview above.
} headerBackground: {
    // A background view, like the gradient in the preview above.

    // Image("test")
    //    .resizable()
    //    .scaledToFill()

    // LinearGradient(...)
            
    // Color.gray
} headerContent: {
    // The header content. Could be Text and Image elements like in the preview above.
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages