Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Kimwolf Botnet Swamps Anonymity Network I2P – Krebs on Security

    February 27, 2026

    ios – How can I have a ScrollView scroll its contents to align with another View’s bottom edge?

    February 27, 2026

    How Cybersecurity Thinking Must Adapt in the Age of AI

    February 27, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – How can I have a ScrollView scroll its contents to align with another View’s bottom edge?
    iOS Development

    ios – How can I have a ScrollView scroll its contents to align with another View’s bottom edge?

    big tee tech hubBy big tee tech hubFebruary 27, 2026003 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – How can I have a ScrollView scroll its contents to align with another View’s bottom edge?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I would suggest simply adding padding to the top of the VStack when the view is pulled down. This will allow the date and time to be seen behind the VStack. Some notes:

    • .onScrollGeometryChange can be used to detect when the view is pulled down.
    • You might want to inspect the scroll phase too, so that the header is only shown when the user interacts with the scroll view from rest, not when scrolling long content back into view. To do this, .onScrollPhaseChange can be used.
    • There is a version of .onScrollPhaseChange that provides ScrollPhaseChangeContext to the closure. This makes it possible to examine the scroll offset when the phase changes too. However, I found that it only reports the offset at the moment of phase change, not on a continuous basis. So .onScrollGeometryChange is probably needed too.
    • If you want to mask the date and time when the view is not pulled down then the background probably needs to be applied to the VStack.
    • If the content is short (as in your example), the background can be extended to the bottom of the screen simply by adding a large amount of negative bottom padding. Alternatively, the height for the background could be computed if the geometry of the screen is known, but negative padding is perhaps simpler (and fit for purpose).

    Here is an elaborated example to show it all working:

    struct ContentView: View {
        let headerHeight: CGFloat = 50
        let scrollThreshold: CGFloat = 10
        @State private var isInteractingFromRest = false
        @State private var isHeaderShowing = false
    
        private var dateAndTime: some View {
            // ...
        }
    
        private var storyContent: some View {
            // ...
        }
    
        var body: some View {
            NavigationStack {
                ZStack(alignment: .top) {
                    dateAndTime
                    ScrollView {
                        VStack {
                            storyContent
                        }
                        .frame(maxWidth: .infinity, alignment: .leading)
                        .background {
                            Color.blue
                                .padding(.bottom, -2000)
                        }
                        .padding(.top, isHeaderShowing ? headerHeight : 0)
                    }
                    .onScrollPhaseChange { _, newPhase, context in
                        if newPhase == .interacting {
                            let geo = context.geometry
                            let scrollOffset = geo.contentOffset.y + geo.contentInsets.top
                            isInteractingFromRest = abs(scrollOffset) < 1
                        } else {
                            isInteractingFromRest = false
                        }
                    }
                    .onScrollGeometryChange(for: Bool.self) { geo in
                        let result: Bool
                        if isInteractingFromRest {
                            let scrollOffset = geo.contentOffset.y + geo.contentInsets.top
                            result = scrollOffset < (isHeaderShowing ? scrollThreshold : -scrollThreshold)
                        } else {
                            result = isHeaderShowing
                        }
                        return result
                    } action: { _, newVal in
                        if newVal != isHeaderShowing {
                            withAnimation {
                                isHeaderShowing = newVal
                            }
                        }
                    }
                    .toolbar {
                        ToolbarItemGroup(placement: .topBarTrailing) {
                            Button("Edit") {}
                            Button("Delete", systemImage: "trash") {}
                        }
                    }
                }
                .background(.red.opacity(0.5))
            }
        }
    }
    

    Animation



    Source link

    Align Bottom contents edge iOS scroll ScrollView views
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    swift – SwiftUI: Nested sheets dismissed on app background with TabView + NavigationStack + .navigationDestination (iOS 26)

    February 26, 2026

    swift – How to get iOS LiveActivity to change status to timer completed

    February 25, 2026

    reactjs – Telegram Mini App (iOS) + Vaul Drawer: Virtual keyboard hides input or pushes drawer off-screen

    February 24, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Kimwolf Botnet Swamps Anonymity Network I2P – Krebs on Security

    February 27, 2026

    ios – How can I have a ScrollView scroll its contents to align with another View’s bottom edge?

    February 27, 2026

    How Cybersecurity Thinking Must Adapt in the Age of AI

    February 27, 2026

    4 Steps to Better Results

    February 26, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Kimwolf Botnet Swamps Anonymity Network I2P – Krebs on Security

    February 27, 2026

    ios – How can I have a ScrollView scroll its contents to align with another View’s bottom edge?

    February 27, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.