SwiftUINavigationHeader

main

Easy navigation bar header with parallax scrolling in SwiftUI
alexeichhorn/SwiftUINavigationHeader

SwiftUINavigationHeader

Create a great navigation header like this in SwiftUI with just a few lines of code

import SwiftUINavigationHeader

struct DetailView: View {
    var body: some View {
        NavigationHeaderContainer(bottomFadeout: true) {
            Image("roadster")
                .resizable()
                .scaledToFill()
        } content: {
            
            topView
                .transformEffect(.init(translationX: 0, y: -100))
                .padding(.bottom, -100)
            
            Text(loremIpsum)
                .font(.body)
                .padding(32)
        }

    }
    
    private var topView: some View {
        Image("roadster")
            .resizable()
            .scaledToFill()
            .clipShape(Circle())
            .shadow(radius: 10)
            .frame(width: 200, height: 200, alignment: .center)
    }
}

Subsequent views inside the same NavigationView should have the following added code snippet, to make sure the navigation bar is always in the correct state:

.navigationBarState(.compact, displayMode: .automatic)

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Oct 18 2024 01:58:55 GMT-0900 (Hawaii-Aleutian Daylight Time)